跪求哪位大神帮我解读一下这段VB程序的作用,越详细越好~~~~~

Private Sub Form_Load()
Dim SurStation(1) As String, XNfile(2) As String
SurFile = "D:\micapsdata\surface\tmax-p\" + Right(NmDate, 6) + "02.000"
If Dir(SurFile) = "" Then
Text3.Text = "无"
Text7.Text = "无"
Else
FileNumber1 = FreeFile(0)
Open SurFile For Input As #FileNumber1
Do
Line Input #FileNumber1, Fir
If Fir <> "" Then
If InStr(1, Fir, SurSurStation(0)) > 0 Then
SurTMax = Mid$(Fir, 29, 5)
DoEvents
Text3.Text = SurTMax
End If
If InStr(1, Fir, SurSurStation(1)) > 0 Then
SurTMax = Mid$(Fir, 29, 5)
DoEvents
Text7.Text = SurTMax
End If
End If
Loop Until EOF(1) = True
End If
Close #FileNumber1
SurFile = "D:\micapsdata\surface\tmin-p\" + Right(NmDate, 6) + "14.000"
If Dir(SurFile) = "" Then
Text4.Text = "无"
Text8.Text = "无"
Else
FileNumber1 = FreeFile(0)
Open SurFile For Input As #FileNumber1
Do
Line Input #FileNumber1, Fir
If Fir <> "" Then
If InStr(1, Fir, SurSurStation(0)) > 0 Then
SurTMin = Mid$(Fir, 29, 5)
DoEvents
Text4.Text = SurTMin
End If
If InStr(1, Fir, SurSurStation(1)) > 0 Then
SurTMin = Mid$(Fir, 29, 5)
DoEvents
Text8.Text = SurTMin
End If
End If
Loop Until EOF(1) = True
End If
Close #FileNumber1
SurFile = "D:\micapsdata\surface\tmax-p\" + Right(NmYDate, 6) + "02.000"
If Dir(SurFile) = "" Then
Text1.Text = "无"
Text5.Text = "无"
Else
FileNumber1 = FreeFile(0)
Open SurFile For Input As #FileNumber1
Do
Line Input #FileNumber1, Fir
If Fir <> "" Then
If InStr(1, Fir, SurSurStation(0)) > 0 Then
SurTMax = Mid$(Fir, 29, 5)
DoEvents
Text1.Text = SurTMax
End If
If InStr(1, Fir, SurSurStation(1)) > 0 Then
SurTMax = Mid$(Fir, 29, 5)
DoEvents
Text5.Text = SurTMax
End If
End If
Loop Until EOF(1) = True
End If
Close #FileNumber1
最新回答
昔望

2024-10-02 05:17:25

SurFile = "D:\micapsdata\surface\tmax-p\" + Right(NmDate, 6) + "02.000" 打开类似文件名的文件
按行读取文件内容 判断该行内容是否有 SurSurStation(0)数组元素内容存在,有的话 截取每行第29个字符开始的 5个字符 显示到textbox文本中
大致概括:读取配置文件 功能
追问
"D:\micapsdata\surface\tmax-p\" 是打开路径   + Right(NmDate, 6) + "02.000" 是文件名么???
追答
是的
山城夏秋

2024-10-02 05:28:09

这个程序的大体意思是依次打开3个文件,并查找里面的三个文件里面的两个关键字,找到关键字就返回指定的字符。
关键字是SurSurStation(0)和SurSurStation(1)

每行的文件读取出来后放到Fir中

返回的字符串在SurTMax 中并在指定的textbox中显示。