数据如下:
上面还有N行……
3 ,5233, 1.59
1 ,民V5018, 1.29, 359.5959, 91.0546, 28.521, 180.0003, 268.5425, 28.521
9 ,民V5018, 1.57
1 ,5210, 1.29, 359.5959, 91.0546, 28.521, 180.0003, 268.5425, 28.521
2 ,KK 1, 0, 113.1237, 90.2903, 20.068, 0, 0, 0
3 ,FG 1, 0, 125.2328, 91.1549, 19.622, 0, 0, 0
1 ,民V5017, 1.29, 359.5959, 91.0546, 28.521, 180.0003, 268.5425, 28.521
9 ,民V5018, 1.23
1 ,5210, 1.29, 359.5959, 91.0546, 28.521, 180.0003, 268.5425, 28.521 下面也有N行…… 设置定a="民V5017" b="民V5018"我想要文件中的 "9 ,民V5018, 1.57" 这一行要怎么做呢
条件是用 a来判断b 这行所在的位置 当b下面有a时 把a上面的b这行赋值给C 显示出来这问题问了好久拉 希望高手们帮帮我啊 thenk you
Dim h As Long
Dim s As String
Dim a As String, b As String, c As String
Dim i As Long, j As Long
Dim tmp, temp
a = "民V5017"
b = "民V5018"
h = FreeFile
Open "D:\test.txt" For Binary As h
s = Space(LOF(h))
Get #h, , s
Close
tmp = Split(s, a)
For i = 0 To UBound(tmp) - 1
temp = Split(tmp(i), vbCrLf)
j = UBound(temp)
Do While j >= 0
If InStr(temp(j), b) Then
Debug.Print temp(j)
Exit Do
End If
j = j - 1
Loop
Next
对不对?
Do Until EOD(1)
Line Input #1, strLine
'只要找到 "民V5017" ,就将最后找到的含有 "民V5018" 的行输出。
If strFound > "" And Instr(strLine, "民V5017") Then
MsgBox strFound
Exit Do
End If
'只要没找到 "民V5017" ,总会将最新找到的 "民V5018" 存入变量。
If Instr(strLine, "民V5018") Then strFound = strLine
Loop