I'm reading a file line by line using
Open spFile For Binary Lock Read Write As #1
I'm using this code to print out the line..
Code: Select all
Sub subDumpStringToExcelSheet( _
strpLine As String, _
Optional vpLineNum As Variant _
)
' Dump a string.
Dim intlI As Integer
Dim strlLine As String
Dim intlICols As Integer
Dim intlRows As Integer
Dim objlRange As Object
Dim intlCol As Integer
Dim intlTableNum As Integer
Dim intlRemainder As Integer
Dim intlColsDone As Integer
Dim strlLineNum As String
Dim slChr As String * 1
If IsMissing(vpLineNum) Then
strlLineNum = "No Line number given"
Else
strlLineNum = "Line " & CStr(vpLineNum)
End If
intlTableNum = 0
strlLine = strpLine
Sheets.Add
ActiveCell.Value = "Line >" & strlLine & "<" '& vbCrLf & vbCrLf
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "Length =" & Len(strlLine) '& vbCrLf & vbCrLf
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = strlLineNum '& vbCrLf & vbCrLf
ActiveCell.Offset(2, 1).Select
intlI = 1
intlRows = 1
intlCol = 12
Do
If intlCol > 11 Then
ActiveCell.Offset(4, -1).Select
ActiveCell.Value = intlI & " To " & intlI + 9 '& vbCrLf
ActiveCell.Offset(1, 0).Select
intlCol = 2
intlTableNum = intlTableNum + 1
ActiveCell.Value = "Chr"
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "Asc"
ActiveCell.Offset(1, 0).Select
ActiveCell.Value = "Chr #"
ActiveCell.Offset(-2, 1).Select
End If
slChr = Mid$(strlLine, intlI, 1)
ActiveCell.Offset(0, intlCol) = slChr
ActiveCell.Offset(1, intlCol) = Asc(slChr)
ActiveCell.Offset(2, intlCol) = intlI
intlCol = intlCol + 1
intlI = intlI + 1
Loop Until intlI > Len(strlLine)
MsgBox "@Done."
' ***********************************************************************
End Sub
Line ><
Length =0
No Line number given
1 To 10
Chr
Asc 32
Chr # 1
?Len(line)
.. in the immediate window also gives zero length.
Can anyone tell me why a line with a space on it has length 0 please?
TIA
Lisa