Greg Koc Greg Koc - 1 year ago 133 Question

check a specific character in textbox visual basic?

Lets say i have a textbox containing the string "hello".

Is there a way in which can i check that the 3rd character of textbox.text = "l"?

We are talking about visual basic, of course.


Answer Source

You could use this function

Private Function checkCharacter(thisString As String,
                                searchCharacter As Char,
                                index As Integer)
        Return thisString(index) = searchCharacter
        Return False
    End Try
End Function

Call it like this

Dim result As Boolean = checkCharacter(TextBox1.Text, "l"c, 2)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download