Read File Content and Store it in string Line by Line
-
Hi All, I am developing project in MS-Access with VBA. In MS-Access I have 1 form , which has 1 command Button. For me, When I click the button, it should take and read texfile from path c: and i need to go through loop until all the lines are completed in that file. So I need to Read the textfile one by one line and store that particular line in string and in that string i have to search whether that line starts with 1 or 2. If it starts with 1 i have to give different command or if its starts with 2 then different command. Likewise i need to check for all the lines in that textfile. I tried it in different way, but didnt help. Kindly help me. Its very urgent. Thanks in advance. Regards,
-
Hi All, I am developing project in MS-Access with VBA. In MS-Access I have 1 form , which has 1 command Button. For me, When I click the button, it should take and read texfile from path c: and i need to go through loop until all the lines are completed in that file. So I need to Read the textfile one by one line and store that particular line in string and in that string i have to search whether that line starts with 1 or 2. If it starts with 1 i have to give different command or if its starts with 2 then different command. Likewise i need to check for all the lines in that textfile. I tried it in different way, but didnt help. Kindly help me. Its very urgent. Thanks in advance. Regards,
here is C# example, use any converter for VB
string[] lines = File.ReadAllLines( <FILEPATH> );
then make a loop that will check every line hope this will help
TVMU^P[[IGIOQHG^JSH`A#@`RFJ\c^JPL>;"[,*/|+&WLEZGc`AFXc!L %^]*IRXD#@GKCQ`R\^SF_WcHbORY87??6?N8?BcRAV\Z^&SU~%CSWQ@#2 W_AD`EPABIKRDFVS)EVLQK)JKSQXUFYK[M`UKs*$GwU#(QDXBER@CBN% Rs0~53%eYrd8mt^7Z6]iTF+(EWfJ9zaK-i?TV.C\y -------------------------------------------------------- 128 bit encrypted signature, crack if you can
-
Hi All, I am developing project in MS-Access with VBA. In MS-Access I have 1 form , which has 1 command Button. For me, When I click the button, it should take and read texfile from path c: and i need to go through loop until all the lines are completed in that file. So I need to Read the textfile one by one line and store that particular line in string and in that string i have to search whether that line starts with 1 or 2. If it starts with 1 i have to give different command or if its starts with 2 then different command. Likewise i need to check for all the lines in that textfile. I tried it in different way, but didnt help. Kindly help me. Its very urgent. Thanks in advance. Regards,
Try this...
Dim FILE_NAME As String = "C:\test.txt" Dim tmpLine As String = "" If System.IO.File.Exists(FILE_NAME) = True Then Dim objReader As New System.IO.StreamReader(FILE_NAME) Do While objReader.Peek() <> -1 tmpLine = objReader.ReadLine() If Mid(tmpLine, 1, 1) = "1" Then ' Your code for command 1 ElseIf Mid(tmpLine, 1, 1) = "2" Then ' Your code for command 2 Else ' Your code for anything else End If Loop Else MsgBox("File Does Not Exist") End If