i try to copy the second line from a txt, that works great problem is now i try to make an if-statement that check the txt, is there something in line 2.
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("testfile.txt", True)
MyFile.WriteLine("" + LastMessage + "")
MyFile.Close
rownumber = 0
file = "testfile.txt"
Set fs = CreateObject("Scripting.FileSystemObject")
Set File = fs.OpenTextFile(file , 1, true)
Do While not file.AtEndOfStream
rownumber = rownumber+1
row = (file.ReadLine)
if rownumber = 2 then
new = row
msgbox row
end if
If row = 0 Then
msgbox "nothing found"
else
msgbox "found"
end if
Loop
The if row = 0 will not work, has some one an idea?
Error Message: Incompatible types: ‘[string:””]’
Line: If row = 0 Then
Regards,
matthias
You are comparing a string to a number – the content of
rowwill be a string, so there is a type mismatch when comparing it to a number.Try this to find out if the line contains the number 0:
If you want to know if the row is empty, try this: