在C盘根目录下存在J010064916_174131.log的文件内容为:
[Long_ADSLCheckChannelRate]
UploadRate=224
DownloadRate=2368
我想单独得到UploadRate的值和DownloadRate的值下面的程序为什么不是我想要的结果,请帮忙分析下
Option Explicit
Private Sub Command1_Click()
Dim s, s1, s2, s3, s4
Open "c:\J010064916_174131.log" For Input As #1
Do While Not EOF(1)
Line Input #1, s
'Print s
s3 = InStr(1, s, "UploadRate=")
s4 = InStr(1, s, "DownloadRate=")
s1 = Mid(s, InStr(1, s, "UploadRate=") + 14, 4)
s2 = Mid(s, InStr(1, s, "DownloadRate=") + 13, 4)
If s3 <> 0 Then
Print s1
End If
If s4 <> 0 Then
Print s2
End If
Loop
Close #1
End Sub

解决方案 »

  1.   


    Option Explicit
    Private Sub Command1_Click()
       Dim s, s1, s2, s3, s4
       Open "c:\J010064916_174131.log" For Input As #1
       Do While Not EOF(1)
       Line Input #1, s
       'Print s
       s3 = InStr(1, s, "UploadRate=")
       s4 = InStr(1, s, "DownloadRate=")
       If InStr(s, "=") Then
       s1 = Split(s, "=")(1)
       s2 = Split(s, "=")(1)
       End If
       If s3 <> 0 Then
       Print s1
       End If
       If s4 <> 0 Then
       Print s2
       End If
       Loop
       Close #1
    End Sub
      

  2.   


    Option Explicit
    Private Sub Command1_Click()
    Dim s, s1, s2, s3, s4
    Open "c:\J010064916_174131.log" For Input As #1
    Do While Not EOF(1)
    Line Input #1, s
    'Print s
    s3 = InStr(1, s, "UploadRate=")
    s4 = InStr(1, s, "DownloadRate=")
    s1 = Mid(s, InStr(1, s, "=") + 1, 4)
    s2 = Mid(s, InStr(1, s, "=") + 1, 4)
    If s3 <> 0 Then
    Print s1
    End If
    If s4 <> 0 Then
    Print s2
    End If
    Loop
    Close #1
    End Sub
      

  3.   


    Option Explicit
    Private Sub Command1_Click()
    Dim s, s1, s2, s3, s4
    Open "c:\J010064916_174131.log" For Input As #1
    Do While Not EOF(1)
    Line Input #1, s
    'Print s
    s3 = InStr(1, s, "UploadRate=")
    s4 = InStr(1, s, "DownloadRate=")
    s1 = Mid(s, InStr(1, s, "UploadRate=") + 11, 4)
    s2 = Mid(s, InStr(1, s, "DownloadRate=") + 13, 4)
    If s3 <> 0 Then
    Print s1
    End If
    If s4 <> 0 Then
    Print s2
    End If
    Loop
    Close #1
    End Sub