 |
 |

03-11-2004, 04:57 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: England, Loughborough
Posts: 173
|
|
Extracting lines from a text file :)
|
Hi,
I wonder if somebody could help me here. I have a text file 'Teams.txt' which contains the following:
Wolves vs Charlton Athletic
2
A
Monday
"12:00"
1
RCB
Week No
#2004-03-08#
Wolves vs Fulham
1
A
Monday
"12:00"
2
EHB
Week No
#2004-03-08#
... more teams here
The sequence is repeated after 9 entries, for each fixture. The fixture has information such as time, day, date pitch no etc associated with it. What I want to be able to do is (because there will always be 9 entries) extract the first entry for as many fixtures in the text file. So in effect, what I will end up with is:
Wolves vs Charlton Athletic
Wolves vs Fulham
I have supplied the code I am using to read the file but I've become a bit stuck and would appreciate any help on this matter.
Open App.Path + "Teams.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, strLine
............
Loop
Close #1
Thanks a bunch guys,
MiniMe
|
__________________
Nothing is impossible...
|

03-11-2004, 05:12 PM
|
|
Regular
|
|
Join Date: Jan 2004
Posts: 72
|
|
mmmmk
I think you could do something like this:
Code:
Dim X as Integer
Dim strTemp as String
Dim arrTemp() as String
Open App.Path + "Teams.txt" For Input As #1
strTemp = Input(LOF(1), 1)
Close #1
arrTemp = split(strTemp,vbCrLf)
For X=0 to UBound(arrTemp) Step 10
txtTeams.Text = txtTeams.Text & arrTemp(X)
If X>0 Then
txtTeams.Text = txtTeams.Text & vbCrLf
Next X
|
|

03-11-2004, 05:14 PM
|
 |
Senior Contributor
* Expert *
|
|
Join Date: Oct 2003
Location: Middle of dust and sun.
Posts: 814
|
|
well if all you want is to extract certain data every 10 lines you could:
Code:
If i = 10 Then
Text1.Text = Text1.Text + strline + vbCrLf
i = 1
End If
i = i + 1
put this inside your loop, define i as integer with starting value of 10.
|
__________________
[Impossible is not a fact. It's an opinion. - nba]
|

03-11-2004, 05:32 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: England, Loughborough
Posts: 173
|
|
|
Hi thanx for ur replies, but for some reason, as it stand, I'm getting 10 records of each fixture in my database. Any ideas why?
MiniMe
Open (Path + "/Teams.txt") For Input As #1
rs.Open SQL, con, adOpenStatic, adLockOptimistic
i = 10
Do While Not EOF(1)
Input #1, strLine
If i = 10 Then
newstring = strLine
i = 1
End If
i = i + 1
rs.AddNew
rs!League = newstring
rs.Update
Loop
rs.MoveLast
rs.MoveFirst
Close #1
|
__________________
Nothing is impossible...
|

03-11-2004, 05:58 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Denver, CO
Posts: 16
|
|
|
ok here is the easiets, and IMHO best
Private Sub Command1_Click
Dim hFile as Long
Dim sFilename as String
sFilename = App.Path + "Teams.txt"
hFile = FreeFile
Open sFilename For Input As #hFile
Text1.Text = Input$(LOF(hFile), hFile)
Close #hFile
End Sub
|
|

03-11-2004, 06:09 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: England, Loughborough
Posts: 173
|
|
Hiya!
It was every line with a fixture on that I wanted to display, not the whole file.
Thank you any way. I found a way now
MiniMe
|
__________________
Nothing is impossible...
|

03-11-2004, 06:27 PM
|
|
Newcomer
|
|
Join Date: Nov 2003
Location: Denver, CO
Posts: 16
|
|
|
Please share the Fix so the next person might be able to see.
thanks!
|
|

03-11-2004, 06:34 PM
|
|
Centurion
|
|
Join Date: Dec 2003
Location: England, Loughborough
Posts: 173
|
|
|
It was either of XVBs and VenDiddys contributions above.
MiniMe
|
__________________
Nothing is impossible...
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|
|
|
 |
|