|
-
Aug 25th, 2006, 04:16 AM
#1
Thread Starter
Addicted Member
text file reading
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
-
Aug 25th, 2006, 04:19 AM
#2
Fanatic Member
Re: text file reading
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
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Aug 25th, 2006, 04:19 AM
#3
Fanatic Member
WHETHER YOU SUCCEED OR FAIL IS NOT AS IMPORTANT AS WHETHER YOU TRIED YOUR BEST 
-
Aug 25th, 2006, 04:22 AM
#4
Lively Member
Re: text file reading
Open "C:\DATA.TXT" For Input As #1
Do While Not EOF(1)
Input #1, vDATA
'Process your data.......
Loop
-
Aug 25th, 2006, 04:25 AM
#5
Thread Starter
Addicted Member
Re: text file reading
Thanks shukla. But my main problem is how to get a particular data from a line.
-
Aug 25th, 2006, 04:32 AM
#6
Re: text file reading
CHECK OUT THIS LINK ALSO FOR MORE DETAIL
VB 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
Last edited by shakti5385; Aug 25th, 2006 at 04:41 AM.
-
Aug 25th, 2006, 03:11 PM
#7
Re: text file reading
 Originally Posted by jobs_arghya
Thanks shukla. But my main problem is how to get a particular data from a line.
That depends on the format of the line and what specific data you want to get.
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Aug 26th, 2006, 12:02 AM
#8
Re: text file reading
 Originally Posted by jobs_arghya
Thanks shukla. But my main problem is how to get a particular data from a line.
Check out the post 6
-
Aug 26th, 2006, 04:11 AM
#9
Thread Starter
Addicted Member
Re: text file reading
Thanks Shakti, At last I found a way. Hope it will work. Thanks a lot
-
Aug 26th, 2006, 04:19 AM
#10
Re: text file reading
 Originally Posted by jobs_arghya
Thanks Shakti, At last I found a way. Hope it will work. Thanks a lot
Your Most Welcome
if get the solution then go to the thread tool menu and click on the resloved this thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|