Hi all,
Can anyody help me out with a code. I want to read a text file line by line and then I will get some data in the lines. I want to do some sort of opeartions may be mathematical on those data.
Please hlp me.
Thank you in advance
Printable View
Hi all,
Can anyody help me out with a code. I want to read a text file line by line and then I will get some data in the lines. I want to do some sort of opeartions may be mathematical on those data.
Please hlp me.
Thank you in advance
CODE IS
VB Code:
Dim f1 dim f2 set f1 =createobject("Scripting.FileSystemObject") set f2 = f1.opentextfile(filename,1) 'open file in read mode while f2.AtEndOfStream=false lineis=f2.readline() wend
then add
f2.close()
Open "C:\DATA.TXT" For Input As #1
Do While Not EOF(1)
Input #1, vDATA
'Process your data.......
Loop
Thanks shukla. But my main problem is how to get a particular data from a line.
CHECK OUT THIS LINK ALSO FOR MORE DETAILVB Code:
Private Sub Command1_Click() Dim strLine As String, Value1 As String, Value2, Value3, Value4, Value5 As String Dim tmpDate As String Dim x As Integer Dim strData() As String tmpDate = DTPicker1 Open "D:\sample2.txt" For Input Lock Write As #1 Open "D:\daily.txt" For Output As #2 Do While (Not EOF(1)) ReDim Preserve strData(x) Line Input #1, strLine If InStr(1, strLine, tmpDate) Then Parts = Split(strLine, ",") Value1 = Parts(0) Value2 = Parts(1) Value3 = Parts(2) Value4 = Parts(3) Value5 = Parts(4) Print #2, Value3;" ";Value1;" ";Value2 End If strData(x) = Value3 + " " + Value1 + " " + Value2 Print #2, strData(x) x = x + 1 Loop Close #1 Close #2 End Sub
That depends on the format of the line and what specific data you want to get.Quote:
Originally Posted by jobs_arghya
Check out the post 6 :confused:Quote:
Originally Posted by jobs_arghya
Thanks Shakti, At last I found a way. Hope it will work. Thanks a lot
Your Most Welcome :thumb:Quote:
Originally Posted by jobs_arghya
if get the solution then go to the thread tool menu and click on the resloved this thread :thumb: