Greg Koc Greg Koc - 4 months ago 51 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.



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)