如何在字符串中查找字符

时间:2012-12-06 22:04:35

标签: substring indexof

我正在尝试使用textbox1中的字符串并查找第3个'e'并告诉它的索引 例如,如果有人输入奶酪,那么它的索引

到目前为止,我有

Dim word As String = TextBox2.Text
Dim x As String
Dim counter As Integer
Dim Letter As String
Dim word1 As String
x = 0
word1 = word.ToLower()
Do
    If word1.Substring(x, 1) = "e" Then counter = counter + 1 And x = x + 1
Loop Until counter = 3 Or counter <> 3
If counter <> 3 Then MsgBox("There are only " & counter & "e's in the inputted string") Else ListBox2.Items.Add(Letter)

0 个答案:

没有答案