.txt manipulation

Add-in Express™ Support Service
That's what is more important than anything else

.txt manipulation
I can't make .readline work.... 
Roger James Tan




Posts: 6
Joined: 2009-03-10
Hi,
Good morning! I cannot make .readline to work for the program i am making. There is a text file that i needed to read the content and compare it to another value. If i try to output it to a msgbox the message is null even if the text file has a lot of text in it. that means it didn't read any line on the text file. Thank you so much.

Roger James Tan,
Posted 13 Mar, 2009 23:44:10 Top
Eugene Astafiev


Guest


Hello Roger,

I have a bunch of questions for you:
1. Do you use Add-in Express? What version and build number of Add-in Express do you use?
2. Do you develop a COM add-in?
3. Could you tell me where in the code do you try to read a file?
4. May I see the code snippet?
Posted 16 Mar, 2009 09:30:34 Top
Roger James Tan




Posts: 6
Joined: 2009-03-10
Hi Eugene,

I'm using an add-in it is the latest version. It is COM add-in.

Dim FILE_NAME As String = getVirt() & "\ErrDesc.txt"

Dim Di As Integer

Dim Num As String

Dim Desc As String

Dim Errdate As String

Dim ErrFile As String

Dim ErrNum As Integer

Dim ErrWrite As String

Dim textLine As String = ""



Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)

Dim objReader As New System.IO.StreamReader(FILE_NAME)




Di = Err.LastDllError

Desc = strErrDesc

Errdate = Date.Today

ErrFile = lngErrNo





Do While objReader.Peek <> -1



MsgBox(objReader.ReadLine())
<----here's the problem, messagebox is null.
textLine =(objReader.Readline() & vbNewLine <---- the Readline should store its message here.

MsgBox(Err.LastDllError & "---" & Err.ToString & "---" & strErrDesc)

ErrWrite = (ErrNum.ToString & " ------- " & Desc & " ------- " & ErrFile & " ------- " & Err.Erl.ToString & " ------- " & " ------- " & Errdate & " ------ ")



<-----it will be use here to compare the current error to the error that has occured.

If ErrWrite.ToString = textLine Then

MsgBox("This error has occured")



objReader.Close()

objWriter.Close()



Exit Sub

Else

objWriter.WriteLine(ErrWrite) '(ErrNum.ToString & " ------- " & Desc & " ------- " & ErrFile & " ------- " & Err.Erl.ToString & " ------- " & " ------- " & Errdate & " ------ ")

objReader.Close()

objWriter.Close()

MsgBox("sample")

Exit Sub

End If

Num += 1

Loop




Else

MsgBox("File Does Not Exist!")

End If

End If

my coding it is a mess right now i cant continue with the code unless i've figure out how to read the line. Thank you.
Posted 16 Mar, 2009 19:45:52 Top
Eugene Astafiev


Guest


Hi Roger,

I'm using an add-in it is the latest version


Sorry, I don't understand you. Do you use Add-in Express?

my coding it is a mess right now i cant continue with the code unless i've figure out how to read the line.


Did you try to debug?
Posted 17 Mar, 2009 05:31:30 Top
Roger James Tan




Posts: 6
Joined: 2009-03-10
Hi Eugene,

Sorry, I mean I am using an add-in and it is the latest version..

I've solved(I simplified the code) the problem now but another came out. I will try to go figure it out again. I will keep you updated. Thank you.
Posted 17 Mar, 2009 19:23:18 Top