Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

IndexOf is case sensitive.

 

That's why I told you to use the RegEx.

But then PlausiblyDamp came up with than enginious idea... works! :p

 

If you need multiple results whithin a string, then you'll have to use RegEx... sorry :-\

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.
  • *Experts*
Posted
Well, for multiple results you could use a loop, but in that case RegEx might be easier.

"Being grown up isn't half as fun as growing up

These are the best days of our lives"

-The Ataris, In This Diary

Posted

Here what I use to search for the text in the listview, the thing is as you can see it is going to select the last value that has that text, what I want is stop at the first one and be able by pressing the button again to select the next line that has the text

Private Sub CmdBgtSearchLOBJ_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdBgtSearchLOBJ.Click
For Each lv In LstBgtLOBJ.Items
           'Check if the description is in the list
           If TxtBgtLOBGJDescription.Text.CompareTo("") = 1 Then
               If lv.SubItems(1).Text.ToLower.IndexOf(TxtBgtLOBGJDescription.Text.ToLower) >= 0 Then
                   lv.Selected = True
                   LstBgtLOBJ.Items(lv.Index).Selected = True
                   LstBgtLOBJ.EnsureVisible(lv.Index)
                   LstBgtLOBJ.Focus()
               End If
               Exit For
           End If
Next
End Sub

Posted

I think you're trying to re-invent the wheel but as cube... :p

How much time did you spent writing and testing that code? ;)

 

If you did use that same time to learn RegEx, it would:

- Be extremelly easy to do (in your present case).

- Astronomically faster, even returning all results at once.

- If, later on, you need to change something on that code you wouldn't need to stop thinking "What in hell is this 'TxtBgtLOBGJDescription.Text.CompareTo("") = 1' here for?".

 

Don't get me wrong, but VB devellopers (as myself) usually tend to complicate the code, discarding the new/easyer/faster techs...

 

Alex :p

Software bugs are impossible to detect by anybody except the end user.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...