is this code is possible?
hi, it is possible to made like with this code?
lets say...
i have a Text1.Text and set as multiline = you will right your own message
then... if the Text1.Text received "HI" i want the msg Box appear Found "HI" then go typing... if Text1.Text received again" hello i want the msg box appear Found "HELLO"
is this possible?
i tried like this but get no luck
VB Code:
Do
if InStr(Text1.Text, "HI") Then
MsgBox("Found: HI")
Else
End if
if InStr(Text1.Text, "Hello") Then
MsgBox("Found: Hello")
Else
End if
Loop
thanks..
Re: is this code is possible?
Are there specific words you want to find in the text?
Re: is this code is possible?
yes... example... Hi, Hello, You,
thanks.
Re: is this code is possible?
Try
VB Code:
Private Sub Command1_Click()
Dim strSearchFor As String
Dim intFound As Integer
strSearchFor = "Hi"
intFound = InStr(Text1.Text, strSearchFor) ' look for word.
If intFound Then ' If found,
Text1.SelStart = intFound - 1 ' set selection start and
Text1.SelLength = Len(strSearchFor) ' set selection length.
MsgBox "Word found"
Else
MsgBox "Word not found."
End If
End Sub
Re: is this code is possible?
@Hack
your code works... but i dont want to press a command button...
let say if i type on Text1.Text Hi it will appear automatically the msgbox..
thanks..
Re: is this code is possible?
just place the code in to the desired event of the textbox like on_change, validate, lostfocus, exit
Re: is this code is possible?
Quote:
Originally Posted by nokmaster
@Hack
your code works... but i dont want to press a command button...
let say if i type on Text1.Text Hi it will appear automatically the msgbox..
thanks..
All code that I post is posted as an example. Generally speaking, I have very little idea of how the member asking the questions wishes to use the code (and often, I have no idea at all).
If you don't want to use the code in a click event, then move to the Change. I would submit that the keypress event should not be considered unless you want to the code to fire every single time you press a key, which could get very, very annoying to whoever is doing the typing.