How to read a text file line by line that contains multiple lines in visual basic
Posted on 2007-10-14
Hello fellas, here is the deal:
I have an input text file like this:
"Please enter user name followed by an equal to operator and further followed by Records Management contact name"
And my VB code to read the input file is like this:
Open "C:\file.txt" For Input As #1
Do Until EOF(1)
Line Input #2, sUserRecMgtCnt
iIndex1 = InStr(Trim(sUserRecMgtCnt), "=")
sUserInput = Mid(Trim(sUserRecMgtCnt), 1, iIndex1 - 1)
I am able to get the first part of the line (until the'=' operator) but I dont understand how I could capture the word past the '=' operator. I tried using the Chr$(13) (and Chr$(10)) for capturing the carriage return and/or new line character, but totally in vain.
So, I would like to know how to capture the second part of the string from '=' operator. Also, the second question is -
While reading the above input file, I have a standard comment in the beginning "Please enter user name followed by...da.da...daaa.daa...daaaa..daaa"
I want this line be ignored while reading the input. How could I do that?
Thanks for any help offered