Suppose I have enter my name ';shakti'; in text1 and in ';a'; in text2 then I click on command button. How do I get answer 3 in text3 because ';a'; is 3rd character in word ?
I need to know because this is my last problem to solve program.How can I get position of a character from word through VB Coding ?
Try this ....
Private Sub Command1_Click()
Dim i As Integer
Dim found As Boolean
i = 1
found = False
While ((Not found) And (i %26lt;= Len(Text1.Text)))
If Mid(Text1.Text, i, 1) = Left(Text2, 1) Then
found = True
Else
i = i + 1
End If
Wend
If found Then
MsgBox (';Found '; %26amp; Left(Text2.Text, 1) %26amp; '; at position '; %26amp; i)
Else
MsgBox (';The character '; %26amp; Left(Text2.Text, 1) %26amp; '; was not found!!!';)
End If
End Sub
Hope that helpsHow can I get position of a character from word through VB Coding ?
most versions of VB have the Instring function
t3 = instr(t1,t2)
No comments:
Post a Comment