by Dan Owen (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Tue 7th August 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
This code will let you write to a file without an extra linefeed being saved. It uses the Print # Statement.
API Declarations
'Put a text box on your form named "Text1"
'Put two command buttons on your form named "Command1" and "Command2"
Command1.Caption = "Normal"
Command2.Caption = "Enhanced"
End Sub
Private Sub Command1_Click()
'This code will save a file normally, with
'the extra line at the end.
Open "C:\Test.txt" For Output As #1
Print #1, Text1.Text
Close #1
End Sub
Private Sub Command2_Click()
'This code will save a file without
'an extra line at the end. Please note
'the ";" after "Text1.Text" this is the
'trick. It will make the next printing
'position directly after the end of the
'string. BUT, since we aren't going to
'print anything else...
Open "C:\Test.txt" For Output As #1
Print #1, Text1.Text;
Close #1
End Sub
No comments have been posted about This code will let you write to a file without an extra linefeed being saved. It uses the Print # S. Why not be the first to post a comment about This code will let you write to a file without an extra linefeed being saved. It uses the Print # S.