Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic file i/o HELP PLEASE !!

Status
Not open for further replies.

TRYP

Programmer
Joined
Jun 20, 2000
Messages
136
Location
US
i need to read a file line by line
NO PROBLEM
However...
i need to include in the read any leading spaces

example:
input #1, temp
'on a line like this
xxxxx
should be
temp=" xxxxx"
but i get
temp="xxxxx"
any ideas ???


tryp
 
Use the Line Input command:
Code:
Dim sLine
Open "C:\Test.txt" For Input As #1
    Do While Not EOF(1)
        Line Input #1, sLine
        MsgBox sLine
    Loop
Close #1
 
'Trim (MyString) will remove leading and trailing spaces in MyString.
'LTrim (MyString) will remove only leading spaces in MyString.
'RTrim (MyString) will remove only trailing spaces in MyString
'For Example:

MyString = " MyText "
String1 = Trim(MyString) 'String1= "MyText".
String1 = LTrim(MyString) 'String1= "MyText ".
String1 = RTrim(MyString) 'String1= " MyText".

Eric De Decker
vbg.be@vbgroup.nl

Licence And Copy Protection AxtiveX
Source CodeBook for the programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top