VBA question

blueshark

Board Regular
Joined
Mar 21, 2003
Messages
54
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
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Never mind. I fixed it. Still not 100% sure waht teh problem was but moving loop statement into sub fixed it.
 
Upvote 0

Forum statistics

Threads
1,221,522
Messages
6,160,307
Members
451,637
Latest member
hvp2262

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top