The code below won't print sParam. I could swear I had this working Friday but I guess that each time it goes through and resets sParam for each line. This is a subroutine that I am looping through. The file I am working with starts with a header row that has the T. Any ideas on how to keep the sParam once it is set?
Private Sub ParseLine(iPosition As Integer)
Dim sLine As String
Dim sDate As String
Dim sTime As String
Dim sCurDate As Date
Dim sParam As String
Dim sValue As String
sCurDate = Date
' Get a line of input
Line Input #1, sLine
' If the line is blank, skip
If Trim(sLine) <> "" Then
If Left(Trim(sLine), 1) = "T" Then
sParam = Mid(Trim(sLine), iPosition, 10)
End If
If Left(Trim(sLine), 1) <> "T" Then
sDate = Left(Trim(sLine), 5) & "/" & Right(sCurDate, 4)
sTime = Mid(Trim(sLine), 7, 5)
sValue = Mid(Trim(sLine), iPosition, 10)
End If
Debug.Print sDate & " " & sTime & " " & Trim(sParam) & " " & Trim(sValue)
End If
End Sub
Private Sub ParseLine(iPosition As Integer)
Dim sLine As String
Dim sDate As String
Dim sTime As String
Dim sCurDate As Date
Dim sParam As String
Dim sValue As String
sCurDate = Date
' Get a line of input
Line Input #1, sLine
' If the line is blank, skip
If Trim(sLine) <> "" Then
If Left(Trim(sLine), 1) = "T" Then
sParam = Mid(Trim(sLine), iPosition, 10)
End If
If Left(Trim(sLine), 1) <> "T" Then
sDate = Left(Trim(sLine), 5) & "/" & Right(sCurDate, 4)
sTime = Mid(Trim(sLine), 7, 5)
sValue = Mid(Trim(sLine), iPosition, 10)
End If
Debug.Print sDate & " " & sTime & " " & Trim(sParam) & " " & Trim(sValue)
End If
End Sub