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