特定字符间循环取字符串处理
sn.rar
(768 Bytes)
我一文本文件,导入数组,属特定字符间循环取字符串处理问题,如附件所示,代码如下:程序代码:
Open ypdialog.FileName For Binary As #1 s = Space(LOF(1)) Get #1, , s s = Replace(s, Chr$(10), Chr$(13)) Do Until InStr(1, s, Chr$(13) & Chr$(13), 0) = 0 s = Replace(s, Chr$(13) & Chr$(13), Chr$(13)) Loop ss = Split(s, Chr$(13)) For i = 0 To UBound(ss) '///////////////////////////////////////////////////////////00AA If InStr(1, ss(i), "LOCATION : 00AA") <> 0 Then n1 = i + 1 ordertxt.Text = ordertxt.Text & n1 & vbCrLf If n1 <> 0 Then For j = n1 To UBound(ss) HAND.Add Mid(ss(j), 1, 8) COM.Add Trim(Mid(ss(j), 9, 15)) If InStr(1, ss(j), " | | BONDED | REQUEST | STKROOM | ASSIGN | MAKER |") <> 0 Then Exit For End If Next j End If End If If InStr(1, ss(i), "LOCATION : 00BB") <> 0 Then n2 = i + 1 If n2 <> 0 Then For j = n2 To UBound(ss) HAND.Add Mid(ss(j), 1, 8) COM.Add Trim(Mid(ss(j), 9, 15)) If InStr(1, ss(j), " | | BONDED | REQUEST | STKROOM | ASSIGN | MAKER |") <> 0 Then Exit For End If Next j End If End If If InStr(1, ss(i), "LOCATION : 00CC") <> 0 Then n3 = i + 1 If n3 <> 0 Then For j = n3 To UBound(ss) HAND.Add Mid(ss(j), 1, 8) COM.Add Trim(Mid(ss(j), 9, 15)) If InStr(1, ss(j), " | | BONDED | REQUEST | STKROOM | ASSIGN | MAKER |") <> 0 Then Exit For End If Next j End If End If Next i Close #1
'但不知道哪里问题,第一个特定字符串间的内容被循环了两次?
大家帮忙看看,如何改!
谢谢!