vbscript read from file is giving strange result

Viewed 43

Sorry about the wrong variable last time but it still acts the same. I must be doing something else wrong but I just can't see it. I'm having trouble reading files. It seems I am doing something wrong as I only get empty strings as answer (with either method). Files are .job but it doesn't work if I change them to .txt either. 'First is strange symbol (y with roof, p and b combined and L) and then gives empty strings and the amount isn't the same as number of lines in the document I've tried it several ways

MsgBox "Open: " & vbCR & FSO.GetAbsolutePathName(jFile) 'this is OK
                    Set objTextFile = objFSO.OpenTextFile(FSO.GetAbsolutePathName(jFile))
                    Do Until objTextFile.AtEndOfStream
                        strText = objTextFile.ReadLine
                        MsgBox strText
                    Loop
                    objTextFile.Close



Dim FSO, cFolder, jFolder, fName, fAnswer, dFolder, dFlag, objFSO, strText, splitText, objTextFile
Const ForReading=1
Set fso = CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
MsgBox "Open: " & vbCR & FSO.GetAbsolutePathName(jFile)'This works fine
                    Set objTextFile = objFSO.OpenTextFile _
                    (FSO.GetAbsolutePathName(jFile), ForReading)
                    Do Until objTextFile.AtEndOfStream
                        strText = objTextFile.ReadLine
                        MsgBox strText 'First is strange symbol (y with roof, p and b combined and L) and then gives empty strings and the amount isn't the same as number of lines in the document
                    Loop
                    objTextFile.Close
                    'Set objTextFile = objFSO.OpenTextFile(FSO.GetAbsolutePathName(jFile), ForReading)
                    'strText = objTextFile.ReadAll
                    'objTextFile.Close
                    'splitText= Split(strText, vbCrLf)
                    'For Each strLine in splitText
                        'MsgBox strLine
                    'Next
0 Answers
Related