0
我有10行數組是第一個名字空間的姓氏空間郵政編碼。所有的郵政編碼都以不同的數字開頭。有沒有辦法在下面的indexof中替換#1,以便它搜索任何數字字符?VB.net有關數組搜索的問題
'open file
inFile = IO.File.OpenText("Names.txt")
'process the loop instruct until end of file
intSubscript = 0
Do Until inFile.Peek = -1 OrElse intSubscript = strLine.Length
strLine(intSubscript) = inFile.ReadLine
intSubscript = intSubscript + 1
Loop
inFile.Close()
intSubscript = 0
strFound = "N"
Do Until strFound = "Y" OrElse intSubscript = strLine.Length
intIndex = strLine(intSubscript).IndexOf("1")
strName = strLine(intSubscript).Substring(0, intIndex - 1)
If strName = strFullname Then
strFound = "Y"
strZip = strLine(intSubscript).Substring(strLine(intSubscript).Length - 5, 5)
txtZip.Text = strZip
End If
Loop
End Sub
您應該使用'Boolean'而不是'strFound'。 – SLaks 2011-05-01 16:16:34