❓ [Help] Searching A Textbox

Posts 31–40 of 40 · Page 3 of 3
Quote Originally Posted by Jason View Post


You won't be able to highlight then, so Find All is pretty useless, all you'll be able to do is test if the textbox contains the search string, that's it.

@Lyoto Machida, your method never worked properly in the first place.
Works with me /me
Quote Originally Posted by Lyoto Machida View Post


Works with me /me
Okay put

Hello World in the textbox and search for the text "Hello"
Quote Originally Posted by Jason View Post


Okay put

Hello World in the textbox and search for the text "Hello"
Yes it works :



Just used this code:
(Textbox1 = Your TExt , txtSearch = You text to search)
[highlight=VB.NET]
If Textbox1.Text.Contains(txtSearch.Text) Then
Textbox1.SelectionStart = Textbox1.Text.IndexOf(txtSearch.Text)
Textbox1.SelectionLength = txtSearch.Text.Length
Textbox1.Select()
Else
If Textbox1.Text.Contains(UCase(txtSearch.Text)) Then
Textbox1.SelectionStart = Textbox1.Text.IndexOf(UCase(txtSearch.Text))
Textbox1.SelectionLength = txtSearch.Text.Length
Textbox1.Select()
Else
Try
Textbox1.SelectionStart = Textbox1.Text.IndexOf(LCase(txtSearch.Text))
Textbox1.SelectionLength = txtSearch.Text.Length
Textbox1.Select()
Catch ex As Exception
MsgBox("Not FOUND")
End Try


End If
End If

[/highlight]

The only problem in my code is: Just find the first "word" example:
There is 2 Hellos

Then i seach Hello

It just highlight the first one , Idk how to search the next one
@Jason it still works =)
Quote Originally Posted by Lyoto Machida View Post


Yes it works :



Just used this code:
(Textbox1 = Your TExt , txtSearch = You text to search)
[highlight=VB.NET]
If Textbox1.Text.Contains(txtSearch.Text) Then
Textbox1.SelectionStart = Textbox1.Text.IndexOf(txtSearch.Text)
Textbox1.SelectionLength = txtSearch.Text.Length
Textbox1.Select()
Else
If Textbox1.Text.Contains(UCase(txtSearch.Text)) Then
Textbox1.SelectionStart = Textbox1.Text.IndexOf(UCase(txtSearch.Text))
Textbox1.SelectionLength = txtSearch.Text.Length
Textbox1.Select()
Else
Try
Textbox1.SelectionStart = Textbox1.Text.IndexOf(LCase(txtSearch.Text))
Textbox1.SelectionLength = txtSearch.Text.Length
Textbox1.Select()
Catch ex As Exception
MsgBox("Not FOUND")
End Try


End If
End If

[/highlight]

The only problem in my code is: Just find the first "word" example:
There is 2 Hellos

Then i seach Hello

It just highlight the first one , Idk how to search the next one
@Jason it still works =)
Not the same code you posted earlier
Okay use that same string, then try search for "hello"
Quote Originally Posted by Jason View Post

Not the same code you posted earlier
Okay use that same string, then try search for "hello"
You're the pro, So edit my code and make it better
But Hello and hello isnt the same =/ i just search for what he want and if not found search for ucase , if not founf search for lcase, I dont know a way that can search both at the same time..
Quote Originally Posted by Lyoto Machida View Post


You're the pro, So edit my code and make it better
But Hello and hello isnt the same =/ i just search for what he want and if not found search for ucase , if not founf search for lcase, I dont know a way that can search both at the same time..
Convert both to ucase instead of comparing them separately.
Quote Originally Posted by Hassan View Post


Convert both to ucase instead of comparing them separately.
Idk how.
Quote Originally Posted by Lyoto Machida View Post


Idk how.
Wait let me get this straight, you know how to convert a string to uppercase, but you don't know how to do two at once?
Quote Originally Posted by Jason View Post


You won't be able to highlight then, so Find All is pretty useless, all you'll be able to do is test if the textbox contains the search string, that's it.

@Lyoto Machida, your method never worked properly in the first place.
Ohhh... Hmm.. Well the thing is, in richtextbox, you can't rightclick and say copy/paste/cut/etc... So thats why i'm using a textbox....
Quote Originally Posted by Cryptonic View Post


Ohhh... Hmm.. Well the thing is, in richtextbox, you can't rightclick and say copy/paste/cut/etc... So thats why i'm using a textbox....
THATS A DUMB THING! -.-
YOU CAN JUST MAKE A CONTEXT MENU STRIP OH MY FUKIN GOD

But i did this:

Code:
        If InStr(Textbox1.Text, txtSearch.Text, CompareMethod.Text) Then
            Textbox1.SelectionStart = InStr(Textbox1.Text, txtSearch.Text, CompareMethod.Text) - 1
            Textbox1.SelectionLength = txtSearch.Text.Length
            Textbox1.Select()
        End If
Working!!!

But its not like a button "next" , it just find the first one.
Posts 31–40 of 40 · Page 3 of 3
This thread is closed for replies.
Talk with us