Dear Colleagues,
I am a new VB learner. I am frostrated with the following question. I am trying to read a file that has several lines of the following data:
1 6 2000 12 05 AM 4.99 4.58 2.85
I created the following small program to achieve that:
Dim p As String * 2
Dim trash As String * 200
Dim date2 As Single
Dim dy, mt, yr, hr1, mn, d1, d2, d3, d4 As Single
Open "c:\work\Eff-Rain\test-00.txt" For Input As #1
Open "C:\Work\Eff-Rain\test-00.dat" For Output As #2
Line Input #1, trash 'this is to read the title line
Do Until EOF(1)
Input #1, dy, mt, yr, hr1, mn, p, d1, d2, d3
If p = "AM" Then
Else
hr1 = hr1 + 12
End If
date2 = 152 + dy - 1 + (hr1 + mn / 60) / 24
d1 = d1 * 0.01
d2 = d2 * 0.01
d3 = d3 * 0.01
Print #2, date2, dy, mt, yr, hr1, mn, p, d1, d2,d3
Loop
lbldone.Caption = "Data processing is done"
End Sub
This program works when I trim the input line to the following:
Input #1, dy, mt, yr, hr1, mn, p
The output is the way I want; but when I try to include the other 3 variables d1, d2 and d3 It tells me that there is a type mismatch. I checked it several time and I spend several hours to try to understand what is going gone; but I could not. Please help me solve this basic question. Thanks.
a VBLearner
I am a new VB learner. I am frostrated with the following question. I am trying to read a file that has several lines of the following data:
1 6 2000 12 05 AM 4.99 4.58 2.85
I created the following small program to achieve that:
Dim p As String * 2
Dim trash As String * 200
Dim date2 As Single
Dim dy, mt, yr, hr1, mn, d1, d2, d3, d4 As Single
Open "c:\work\Eff-Rain\test-00.txt" For Input As #1
Open "C:\Work\Eff-Rain\test-00.dat" For Output As #2
Line Input #1, trash 'this is to read the title line
Do Until EOF(1)
Input #1, dy, mt, yr, hr1, mn, p, d1, d2, d3
If p = "AM" Then
Else
hr1 = hr1 + 12
End If
date2 = 152 + dy - 1 + (hr1 + mn / 60) / 24
d1 = d1 * 0.01
d2 = d2 * 0.01
d3 = d3 * 0.01
Print #2, date2, dy, mt, yr, hr1, mn, p, d1, d2,d3
Loop
lbldone.Caption = "Data processing is done"
End Sub
This program works when I trim the input line to the following:
Input #1, dy, mt, yr, hr1, mn, p
The output is the way I want; but when I try to include the other 3 variables d1, d2 and d3 It tells me that there is a type mismatch. I checked it several time and I spend several hours to try to understand what is going gone; but I could not. Please help me solve this basic question. Thanks.
a VBLearner