hi all,
i am having problems using the Trim() function in a program written in VB6. i'm getting my strings from reading a textfile line by line, but regardless of the trim function a couple of extra spaces are always included in the variable.
this is the code i use:
[code=vb]
Dim filepath As String
Dim FileNo As Long
Dim LineNo, i As Integer
Dim LineText As String
FileNo = FreeFile ' Get next available file number.
cdb.ShowOpen
filepath = cdb.FileName
Open filepath For Input Access Read Shared As #FileNo
Do Until EOF(FileNo) ' Repeat until end of file...
Line Input #FileNo, LineText ' Read a line from the file.
LineNo = LineNo + 1
txtFileName.Tex t = Trim(LineText) ' This line still leaves a couple of spaces at the end of the string in txtFileName.Tex t
DoEvents ' Allow Windows to handle other tasks.
Loop
Close #FileNo
[/code]
why doesn't the Trim() function remove all tracing spaces?
i am having problems using the Trim() function in a program written in VB6. i'm getting my strings from reading a textfile line by line, but regardless of the trim function a couple of extra spaces are always included in the variable.
this is the code i use:
[code=vb]
Dim filepath As String
Dim FileNo As Long
Dim LineNo, i As Integer
Dim LineText As String
FileNo = FreeFile ' Get next available file number.
cdb.ShowOpen
filepath = cdb.FileName
Open filepath For Input Access Read Shared As #FileNo
Do Until EOF(FileNo) ' Repeat until end of file...
Line Input #FileNo, LineText ' Read a line from the file.
LineNo = LineNo + 1
txtFileName.Tex t = Trim(LineText) ' This line still leaves a couple of spaces at the end of the string in txtFileName.Tex t
DoEvents ' Allow Windows to handle other tasks.
Loop
Close #FileNo
[/code]
why doesn't the Trim() function remove all tracing spaces?
Comment