[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.vb.general.discussion

Subscript out of range, obvious?

Dave Cullen

2/19/2011 11:28:00 PM

I have nice little module that reads CSV lines of a text file, removes the
commas, and displays the 4 items/line in nice columns.
It works with a test file of 3 lines, but when there are 1 or 2 lines in the
file, it thows a Run time Error 9, Subscript out of range.

Here is the text file contents:
0,Phy Plant,Mech Rm Temp,2/19/2011 12:24:54 AM
3,Equip Mon,R,2/19/2011 12:30:55 AM

here is my code:
------------------
Private Sub Command3_Click() '-- Active Events Display test ---
Dim field() As String
Dim sTemp As String
Dim nI As Integer
Dim TmpTxt As String
FileNum = FreeFile
Tabulator(1) = 20
Tabulator(2) = 30
Tabulator(3) = 55
' Tabulator(4) = 250
' Tabulator(5) = 310
Dim strSQL As String
List1.Clear
Dim strMes As String
'Open App.Path & "\" & "MList.log" For Input As #1
Open "C:\" & "MList.log" For Input As #1
Do Until eof(1)
Line Input #1, TmpTxt
'ListView1.AddItem TmpTxt
field = Split(TmpTxt, ",", 4, vbTextCompare)

For nI = 0 To UBound(field)
sTemp = field(nI)
Next nI
SendMessage List1.hwnd, _
LB_SETTABSTOPS, OBorder, Tabulator(1)

sTemp = field(2) & Space(19 - Len(field(2))) '<- 9, Sup Script OORange
error

List1.AddItem " " & field(0) & vbTab & field(1) & vbTab & sTemp & vbTab &
field(3)
Loop
Close #1
End Sub
------------

The two lines of the file are correctly displayed as intended, the error
occurrs at EOF or some end fail.

Any suggestion greatly appreciated.


41 Answers

GS

2/19/2011 11:37:00 PM

0

Anita presented the following explanation :
> I have nice little module that reads CSV lines of a text file, removes the
> commas, and displays the 4 items/line in nice columns.
> It works with a test file of 3 lines, but when there are 1 or 2 lines in the
> file, it thows a Run time Error 9, Subscript out of range.
>
> Here is the text file contents:
> 0,Phy Plant,Mech Rm Temp,2/19/2011 12:24:54 AM
> 3,Equip Mon,R,2/19/2011 12:30:55 AM
>
> here is my code:
> ------------------
> Private Sub Command3_Click() '-- Active Events Display test ---
> Dim field() As String
> Dim sTemp As String
> Dim nI As Integer
> Dim TmpTxt As String
> FileNum = FreeFile
> Tabulator(1) = 20
> Tabulator(2) = 30
> Tabulator(3) = 55
> ' Tabulator(4) = 250
> ' Tabulator(5) = 310
> Dim strSQL As String
> List1.Clear
> Dim strMes As String
> 'Open App.Path & "\" & "MList.log" For Input As #1
> Open "C:\" & "MList.log" For Input As #1
> Do Until eof(1)
> Line Input #1, TmpTxt
> 'ListView1.AddItem TmpTxt
> field = Split(TmpTxt, ",", 4, vbTextCompare)
>
> For nI = 0 To UBound(field)
> sTemp = field(nI)
> Next nI
> SendMessage List1.hwnd, _
> LB_SETTABSTOPS, OBorder, Tabulator(1)
>
> sTemp = field(2) & Space(19 - Len(field(2))) '<- 9, Sup Script OORange
> error
>
> List1.AddItem " " & field(0) & vbTab & field(1) & vbTab & sTemp & vbTab &
> field(3)
> Loop
> Close #1
> End Sub
> ------------
>
> The two lines of the file are correctly displayed as intended, the error
> occurrs at EOF or some end fail.
>
> Any suggestion greatly appreciated.

I'm thinking the file has an extra line after the last line of data?

What i usually do is dump the text into a variant using Split() and
specifying vbCrLf as the delimiter so I get an array of lines. Then I
use Filter() on the array to remove any blanks. Then I process the
array.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Dave Cullen

2/19/2011 11:48:00 PM

0


"GS" <gs@somewhere.net> wrote in message
news:ijpk5f$ddm$1@news.eternal-september.org...
> Anita presented the following explanation :
>> I have nice little module that reads CSV lines of a text file, removes
>> the commas, and displays the 4 items/line in nice columns.
>> It works with a test file of 3 lines, but when there are 1 or 2 lines in
>> the file, it thows a Run time Error 9, Subscript out of range.
>>
>> Here is the text file contents:
>> 0,Phy Plant,Mech Rm Temp,2/19/2011 12:24:54 AM
>> 3,Equip Mon,R,2/19/2011 12:30:55 AM
>>
>> here is my code:
>> ------------------
>> Private Sub Command3_Click() '-- Active Events Display test ---
>> Dim field() As String
>> Dim sTemp As String
>> Dim nI As Integer
>> Dim TmpTxt As String
>> FileNum = FreeFile
>> Tabulator(1) = 20
>> Tabulator(2) = 30
>> Tabulator(3) = 55
>> ' Tabulator(4) = 250
>> ' Tabulator(5) = 310
>> Dim strSQL As String
>> List1.Clear
>> Dim strMes As String
>> 'Open App.Path & "\" & "MList.log" For Input As #1
>> Open "C:\" & "MList.log" For Input As #1
>> Do Until eof(1)
>> Line Input #1, TmpTxt
>> 'ListView1.AddItem TmpTxt
>> field = Split(TmpTxt, ",", 4, vbTextCompare)
>>
>> For nI = 0 To UBound(field)
>> sTemp = field(nI)
>> Next nI
>> SendMessage List1.hwnd, _
>> LB_SETTABSTOPS, OBorder, Tabulator(1)
>>
>> sTemp = field(2) & Space(19 - Len(field(2))) '<- 9, Sup Script
>> OORange error
>>
>> List1.AddItem " " & field(0) & vbTab & field(1) & vbTab & sTemp & vbTab
>> & field(3)
>> Loop
>> Close #1
>> End Sub
>> ------------
>>
>> The two lines of the file are correctly displayed as intended, the error
>> occurrs at EOF or some end fail.
>>
>> Any suggestion greatly appreciated.
>
> I'm thinking the file has an extra line after the last line of data?
>
> What i usually do is dump the text into a variant using Split() and
> specifying vbCrLf as the delimiter so I get an array of lines. Then I use
> Filter() on the array to remove any blanks. Then I process the array.
>
> --
> Garry
>
> Free usenet access at http://www.eternal-sep...
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
Oh yes!

That was it.

I held down Delete (for a bit) after the last character of the last line,
then saved the file.
Then no error.

That solutions sounds ominous, I'll try.


Dave Cullen

2/19/2011 11:52:00 PM

0

"GS" <gs@somewhere.net> wrote in message
news:ijpk5f$ddm$1@news.eternal-september.org...
> Anita presented the following explanation :
>> I have nice little module that reads CSV lines of a text file, removes
>> the commas, and displays the 4 items/line in nice columns.
>> It works with a test file of 3 lines, but when there are 1 or 2 lines in
>> the file, it thows a Run time Error 9, Subscript out of range.
>>
>> Here is the text file contents:
>> 0,Phy Plant,Mech Rm Temp,2/19/2011 12:24:54 AM
>> 3,Equip Mon,R,2/19/2011 12:30:55 AM
>>
>> here is my code:
>> ------------------
>> Private Sub Command3_Click() '-- Active Events Display test ---
>> Dim field() As String
>> Dim sTemp As String
>> Dim nI As Integer
>> Dim TmpTxt As String
>> FileNum = FreeFile
>> Tabulator(1) = 20
>> Tabulator(2) = 30
>> Tabulator(3) = 55
>> ' Tabulator(4) = 250
>> ' Tabulator(5) = 310
>> Dim strSQL As String
>> List1.Clear
>> Dim strMes As String
>> 'Open App.Path & "\" & "MList.log" For Input As #1
>> Open "C:\" & "MList.log" For Input As #1
>> Do Until eof(1)
>> Line Input #1, TmpTxt
>> 'ListView1.AddItem TmpTxt
>> field = Split(TmpTxt, ",", 4, vbTextCompare)
>>
>> For nI = 0 To UBound(field)
>> sTemp = field(nI)
>> Next nI
>> SendMessage List1.hwnd, _
>> LB_SETTABSTOPS, OBorder, Tabulator(1)
>>
>> sTemp = field(2) & Space(19 - Len(field(2))) '<- 9, Sup Script
>> OORange error
>>
>> List1.AddItem " " & field(0) & vbTab & field(1) & vbTab & sTemp & vbTab
>> & field(3)
>> Loop
>> Close #1
>> End Sub
>> ------------
>>
>> The two lines of the file are correctly displayed as intended, the error
>> occurrs at EOF or some end fail.
>>
>> Any suggestion greatly appreciated.
>
> I'm thinking the file has an extra line after the last line of data?
>
> What i usually do is dump the text into a variant using Split() and
> specifying vbCrLf as the delimiter so I get an array of lines. Then I use
> Filter() on the array to remove any blanks. Then I process the array.
>
> --
> Garry
>
> Free usenet access at http://www.eternal-sep...
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>

Could this also be because of the way I'm clearing the file, between my apps
events?
I'm using :
Open App.Path & "\" & "Loglist.log" For Output As #1
Close #1
I bet if I cleared it (more) properly there would be no hidden blank spaces,
etc.



GS

2/20/2011 12:53:00 AM

0

on 2/19/2011, Anita supposed :
> "GS" <gs@somewhere.net> wrote in message
> news:ijpk5f$ddm$1@news.eternal-september.org...
>> Anita presented the following explanation :
>>> I have nice little module that reads CSV lines of a text file, removes the
>>> commas, and displays the 4 items/line in nice columns.
>>> It works with a test file of 3 lines, but when there are 1 or 2 lines in
>>> the file, it thows a Run time Error 9, Subscript out of range.
>>>
>>> Here is the text file contents:
>>> 0,Phy Plant,Mech Rm Temp,2/19/2011 12:24:54 AM
>>> 3,Equip Mon,R,2/19/2011 12:30:55 AM
>>>
>>> here is my code:
>>> ------------------
>>> Private Sub Command3_Click() '-- Active Events Display test ---
>>> Dim field() As String
>>> Dim sTemp As String
>>> Dim nI As Integer
>>> Dim TmpTxt As String
>>> FileNum = FreeFile
>>> Tabulator(1) = 20
>>> Tabulator(2) = 30
>>> Tabulator(3) = 55
>>> ' Tabulator(4) = 250
>>> ' Tabulator(5) = 310
>>> Dim strSQL As String
>>> List1.Clear
>>> Dim strMes As String
>>> 'Open App.Path & "\" & "MList.log" For Input As #1
>>> Open "C:\" & "MList.log" For Input As #1
>>> Do Until eof(1)
>>> Line Input #1, TmpTxt
>>> 'ListView1.AddItem TmpTxt
>>> field = Split(TmpTxt, ",", 4, vbTextCompare)
>>>
>>> For nI = 0 To UBound(field)
>>> sTemp = field(nI)
>>> Next nI
>>> SendMessage List1.hwnd, _
>>> LB_SETTABSTOPS, OBorder, Tabulator(1)
>>>
>>> sTemp = field(2) & Space(19 - Len(field(2))) '<- 9, Sup Script OORange
>>> error
>>>
>>> List1.AddItem " " & field(0) & vbTab & field(1) & vbTab & sTemp & vbTab &
>>> field(3)
>>> Loop
>>> Close #1
>>> End Sub
>>> ------------
>>>
>>> The two lines of the file are correctly displayed as intended, the error
>>> occurrs at EOF or some end fail.
>>>
>>> Any suggestion greatly appreciated.
>>
>> I'm thinking the file has an extra line after the last line of data?
>>
>> What i usually do is dump the text into a variant using Split() and
>> specifying vbCrLf as the delimiter so I get an array of lines. Then I use
>> Filter() on the array to remove any blanks. Then I process the array.
>>
>> -- Garry
>>
>> Free usenet access at http://www.eternal-sep...
>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>
>
> Could this also be because of the way I'm clearing the file, between my apps
> events?
> I'm using :
> Open App.Path & "\" & "Loglist.log" For Output As #1
> Close #1
> I bet if I cleared it (more) properly there would be no hidden blank spaces,
> etc.

If you're not using a semicolon at the end of the line that writes to
the file then a linefeed is inserted by default. Use the semicolon to
avoid this happening.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Larry Serflaten

2/20/2011 3:02:00 AM

0


"Anita" <no_spam@mail.com> wrote
>
>
> Could this also be because of the way I'm clearing the file, between my apps
> events?
> I'm using :
> Open App.Path & "\" & "Loglist.log" For Output As #1
> Close #1
> I bet if I cleared it (more) properly there would be no hidden blank spaces,
> etc.

No. The contents of your file is determined when you write to it. As you saw
a blank line at the end was written by your editor because the editor's text
contained a blank line at the end.

Also you only need to set tabstops once on a control. Depending on how the
control handles the addition of tabstops already defined, you may run into trouble
if you repeatedly set tabstops without clearing the old values. Something like the
sub below lets you set tabs for any listbox, possibly from the Form_Load event:

Ex:
ListboxTabs List1, 20, 30, 55, 250, 310

HTH
LFS


Public Sub ListboxTabs(Listbox As Listbox, ParamArray Tabs())
Dim UB As Long, item As Long
Const LB_SETTABSTOPS = &H192

' send no tab values to clear all tabs
SendMessage Listbox.hwnd, LB_SETTABSTOPS, 0, 0&
' save tab count
UB = UBound(Tabs)
If UB >= 0 Then
' create tab array of Longs
ReDim TabStops(0 To UB) As Long
For item = 0 To UB
TabStops(item) = Tabs(item)
Next
' set tabs
SendMessage Listbox.hwnd, LB_SETTABSTOPS, UB + 1, TabStops(0)
End If
End Sub


Dave Cullen

2/20/2011 4:30:00 PM

0

"GS" <gs@somewhere.net> wrote in message
news:ijpojn$222$1@news.eternal-september.org...
> on 2/19/2011, Anita supposed :
>> "GS" <gs@somewhere.net> wrote in message
>> news:ijpk5f$ddm$1@news.eternal-september.org...
>>> Anita presented the following explanation :
>>>> I have nice little module that reads CSV lines of a text file, removes
>>>> the commas, and displays the 4 items/line in nice columns.
>>>> It works with a test file of 3 lines, but when there are 1 or 2 lines
>>>> in the file, it thows a Run time Error 9, Subscript out of range.
>>>>
>>>> Here is the text file contents:
>>>> 0,Phy Plant,Mech Rm Temp,2/19/2011 12:24:54 AM
>>>> 3,Equip Mon,R,2/19/2011 12:30:55 AM
>>>>
>>>> here is my code:
>>>> ------------------
>>>> Private Sub Command3_Click() '-- Active Events Display test ---
>>>> Dim field() As String
>>>> Dim sTemp As String
>>>> Dim nI As Integer
>>>> Dim TmpTxt As String
>>>> FileNum = FreeFile
>>>> Tabulator(1) = 20
>>>> Tabulator(2) = 30
>>>> Tabulator(3) = 55
>>>> ' Tabulator(4) = 250
>>>> ' Tabulator(5) = 310
>>>> Dim strSQL As String
>>>> List1.Clear
>>>> Dim strMes As String
>>>> 'Open App.Path & "\" & "MList.log" For Input As #1
>>>> Open "C:\" & "MList.log" For Input As #1
>>>> Do Until eof(1)
>>>> Line Input #1, TmpTxt
>>>> 'ListView1.AddItem TmpTxt
>>>> field = Split(TmpTxt, ",", 4, vbTextCompare)
>>>>
>>>> For nI = 0 To UBound(field)
>>>> sTemp = field(nI)
>>>> Next nI
>>>> SendMessage List1.hwnd, _
>>>> LB_SETTABSTOPS, OBorder, Tabulator(1)
>>>>
>>>> sTemp = field(2) & Space(19 - Len(field(2))) '<- 9, Sup Script
>>>> OORange error
>>>>
>>>> List1.AddItem " " & field(0) & vbTab & field(1) & vbTab & sTemp &
>>>> vbTab & field(3)
>>>> Loop
>>>> Close #1
>>>> End Sub
>>>> ------------
>>>>
>>>> The two lines of the file are correctly displayed as intended, the
>>>> error occurrs at EOF or some end fail.
>>>>
>>>> Any suggestion greatly appreciated.
>>>
>>> I'm thinking the file has an extra line after the last line of data?
>>>
>>> What i usually do is dump the text into a variant using Split() and
>>> specifying vbCrLf as the delimiter so I get an array of lines. Then I
>>> use Filter() on the array to remove any blanks. Then I process the
>>> array.
>>>
>>> -- Garry
>>>
>>> Free usenet access at http://www.eternal-sep...
>>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>>
>>
>> Could this also be because of the way I'm clearing the file, between my
>> apps events?
>> I'm using :
>> Open App.Path & "\" & "Loglist.log" For Output As #1
>> Close #1
>> I bet if I cleared it (more) properly there would be no hidden blank
>> spaces, etc.
>
> If you're not using a semicolon at the end of the line that writes to the
> file then a linefeed is inserted by default. Use the semicolon to avoid
> this happening.
>
> --
> Garry
>
> Free usenet access at http://www.eternal-sep...
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
>

Adding a semicolon to the end of my:
Print #FileNum, Item1 & "," & Item2 & "," & Item3 & "," & Item4
Prevents the text file entries from being on new lines. Its like removing a
vbCrLf.
I have the semicolon off at the moment testing and its working.



Henning

2/20/2011 5:57:00 PM

0


"Anita" <no_spam@mail.com> skrev i meddelandet
news:kkb8p.25013$6J5.13175@newsfe05.iad...
> "GS" <gs@somewhere.net> wrote in message
> news:ijpojn$222$1@news.eternal-september.org...
>> on 2/19/2011, Anita supposed :
>>> "GS" <gs@somewhere.net> wrote in message
>>> news:ijpk5f$ddm$1@news.eternal-september.org...
>>>> Anita presented the following explanation :
>>>>> I have nice little module that reads CSV lines of a text file, removes
>>>>> the commas, and displays the 4 items/line in nice columns.
>>>>> It works with a test file of 3 lines, but when there are 1 or 2 lines
>>>>> in the file, it thows a Run time Error 9, Subscript out of range.
>>>>>
>>>>> Here is the text file contents:
>>>>> 0,Phy Plant,Mech Rm Temp,2/19/2011 12:24:54 AM
>>>>> 3,Equip Mon,R,2/19/2011 12:30:55 AM
>>>>>
>>>>> here is my code:
>>>>> ------------------
>>>>> Private Sub Command3_Click() '-- Active Events Display test ---
>>>>> Dim field() As String
>>>>> Dim sTemp As String
>>>>> Dim nI As Integer
>>>>> Dim TmpTxt As String
>>>>> FileNum = FreeFile
>>>>> Tabulator(1) = 20
>>>>> Tabulator(2) = 30
>>>>> Tabulator(3) = 55
>>>>> ' Tabulator(4) = 250
>>>>> ' Tabulator(5) = 310
>>>>> Dim strSQL As String
>>>>> List1.Clear
>>>>> Dim strMes As String
>>>>> 'Open App.Path & "\" & "MList.log" For Input As #1
>>>>> Open "C:\" & "MList.log" For Input As #1
>>>>> Do Until eof(1)
>>>>> Line Input #1, TmpTxt
>>>>> 'ListView1.AddItem TmpTxt
>>>>> field = Split(TmpTxt, ",", 4, vbTextCompare)
>>>>>
>>>>> For nI = 0 To UBound(field)
>>>>> sTemp = field(nI)
>>>>> Next nI
>>>>> SendMessage List1.hwnd, _
>>>>> LB_SETTABSTOPS, OBorder, Tabulator(1)
>>>>>
>>>>> sTemp = field(2) & Space(19 - Len(field(2))) '<- 9, Sup Script
>>>>> OORange error
>>>>>
>>>>> List1.AddItem " " & field(0) & vbTab & field(1) & vbTab & sTemp &
>>>>> vbTab & field(3)
>>>>> Loop
>>>>> Close #1
>>>>> End Sub
>>>>> ------------
>>>>>
>>>>> The two lines of the file are correctly displayed as intended, the
>>>>> error occurrs at EOF or some end fail.
>>>>>
>>>>> Any suggestion greatly appreciated.
>>>>
>>>> I'm thinking the file has an extra line after the last line of data?
>>>>
>>>> What i usually do is dump the text into a variant using Split() and
>>>> specifying vbCrLf as the delimiter so I get an array of lines. Then I
>>>> use Filter() on the array to remove any blanks. Then I process the
>>>> array.
>>>>
>>>> -- Garry
>>>>
>>>> Free usenet access at http://www.eternal-sep...
>>>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>>>
>>>
>>> Could this also be because of the way I'm clearing the file, between my
>>> apps events?
>>> I'm using :
>>> Open App.Path & "\" & "Loglist.log" For Output As #1
>>> Close #1
>>> I bet if I cleared it (more) properly there would be no hidden blank
>>> spaces, etc.
>>
>> If you're not using a semicolon at the end of the line that writes to the
>> file then a linefeed is inserted by default. Use the semicolon to avoid
>> this happening.
>>
>> --
>> Garry
>>
>> Free usenet access at http://www.eternal-sep...
>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>
>>
>
> Adding a semicolon to the end of my:
> Print #FileNum, Item1 & "," & Item2 & "," & Item3 & "," & Item4
> Prevents the text file entries from being on new lines. Its like removing
> a vbCrLf.
> I have the semicolon off at the moment testing and its working.
>

If I read right, the problem is an empty line.

Does it help if you change to:
Do Until eof(1)
Line Input #1, TmpTxt
'ListView1.AddItem TmpTxt
If Len(TmpTxt) > 3 'or whatever less than the min. length
field = Split(TmpTxt, ",", 4, vbTextCompare)
....rest of
....code
End If
Loop

/Henning


GS

2/20/2011 5:58:00 PM

0

> Adding a semicolon to the end of my:
> Print #FileNum, Item1 & "," & Item2 & "," & Item3 & "," & Item4
> Prevents the text file entries from being on new lines. Its like removing a
> vbCrLf.
> I have the semicolon off at the moment testing and its working.

I see what's happening! You're printing one line at a time. Is there
some reason you can't print the entire file in one shot? OR add the
semicolon to the last line printed? OR Just never process the empty
line?

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc


Dave Cullen

2/20/2011 6:57:00 PM

0

"GS" <gs@somewhere.net> wrote in message
news:ijrkmg$s0h$1@news.eternal-september.org...
>> Adding a semicolon to the end of my:
>> Print #FileNum, Item1 & "," & Item2 & "," & Item3 & "," & Item4
>> Prevents the text file entries from being on new lines. Its like
>> removing a vbCrLf.
>> I have the semicolon off at the moment testing and its working.
>
> I see what's happening! You're printing one line at a time. Is there some
> reason you can't print the entire file in one shot? OR add the semicolon
> to the last line printed? OR Just never process the empty line?
>
> --
> Garry
>
> Free usenet access at http://www.eternal-sep...
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
Well, one line occurs at a time, its not a long string.

Sample data line:
65,System Name,Point Name,Date/Time

As I said about the semicolon, when there are occasions with multiple text
lines stored, adding a semicolon to the end of the Print #FilNum .. line
blows up my one-line-per-event design.

I'n not having any problems with it now, without the semicolon.

Were you suggesting I put a semicolon at the end of each actual stored text
line? Or at the end of this: Print #FileNum, Item1 & "," & Item2 & "," &
Item3 & "," & Item4

I'm going to leave things as is for a few days of lab testing.

See my 18-Feb post under Microsoft.public.vb.database.ado

Thanks all.


GS

2/20/2011 7:18:00 PM

0

on 2/20/2011, Anita supposed :
> "GS" <gs@somewhere.net> wrote in message
> news:ijrkmg$s0h$1@news.eternal-september.org...
>>> Adding a semicolon to the end of my:
>>> Print #FileNum, Item1 & "," & Item2 & "," & Item3 & "," & Item4
>>> Prevents the text file entries from being on new lines. Its like removing
>>> a vbCrLf.
>>> I have the semicolon off at the moment testing and its working.
>>
>> I see what's happening! You're printing one line at a time. Is there some
>> reason you can't print the entire file in one shot? OR add the semicolon to
>> the last line printed? OR Just never process the empty line?
>>
>> -- Garry
>>
>> Free usenet access at http://www.eternal-sep...
>> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>>
> Well, one line occurs at a time, its not a long string.
>
> Sample data line:
> 65,System Name,Point Name,Date/Time
>
> As I said about the semicolon, when there are occasions with multiple text
> lines stored, adding a semicolon to the end of the Print #FilNum .. line
> blows up my one-line-per-event design.
>
> I'n not having any problems with it now, without the semicolon.
>
> Were you suggesting I put a semicolon at the end of each actual stored text
> line? Or at the end of this: Print #FileNum, Item1 & "," & Item2 & "," &
> Item3 & "," & Item4

No, I was suggesting to include the semicolon on your last entry.
Writing each line to file seems a bit inefficient <IMO>.

>
> I'm going to leave things as is for a few days of lab testing.
>
> See my 18-Feb post under Microsoft.public.vb.database.ado

I will look at this...

>
> Thanks all.

--
Garry

Free usenet access at http://www.eternal-sep...
ClassicVB Users Regroup! comp.lang.basic.visual.misc