Searching a textfile - please help 
Author Message
 Searching a textfile - please help

Hello,
I am having trouble with my vb application, i am trying to search a text
file and retrieve the data from it, for instance my text file has is set out
like this "NSW", "Carr", 23000000, 240900 The search will work the first
time that the application is loaded but after that it will not work
properly. I wish to have 2 differnet options using the option controls, the
first option i wish to retrieve the data as it appears on the text file but
i only want to match the first field eg "NSW", the second option i wish to
retrieve the data as appears on the text file but i wish to search and match
with the second field eg "Carr". If some one could help me with this code i
would be most grateful as i have no clue what i am doing wrong. I have a
copy of the source below

Thank You in Advance for you answer

Sean

------------------------------------------------ source code
Private Sub Command1_Click()
Dim sid As String, pname As String, pop As Single, ar As Single
 sid = ""
  pname = ""
   Picture1.Cls
If txtname.Text = "" Then
    Font.Bold = True
     Picture1.FontSize = 14
      Picture1.Print Tab(3); "Please enter something"
Else
      If Option1.Value = True Then
        Do While (sid <> txtname.Text) And (Not EOF(1))
        Input #1, sid, pname, pop, ar
         Picture1.Print sid, pname, pop, ar
        Loop
ElseIf Option2.Value = True Then
          Do While (pname <> txtname.Text) And (Not EOF(1))
          Input #1, sid, pname, pop, ar
           Picture1.Print sid, pname, pop, ar
Loop
End If
End If
End Sub

Private Sub Command2_Click()
Picture1.Cls
txtname.Text = ""
txtname.SetFocus
End Sub

Private Sub Form_Load()
Open "C:\windows\desktop\test\states.txt" For Input As #1
Input #1, sid, pname, pop, ar
End Sub



Mon, 23 Apr 2001 03:00:00 GMT  
 Searching a textfile - please help
Your problem is, that after the first pass thru, the filepointer ist at
"EOF". What you need to do ist make it point again to the beginning of the
file: SEEK #1,1.

Sean schrieb in Nachricht

Quote:
>Hello,
>I am having trouble with my vb application, i am trying to search a text
>file and retrieve the data from it, for instance my text file has is set
out
>like this "NSW", "Carr", 23000000, 240900 The search will work the first
>time that the application is loaded but after that it will not work
>properly. I wish to have 2 differnet options using the option controls, the
>first option i wish to retrieve the data as it appears on the text file but
>i only want to match the first field eg "NSW", the second option i wish to
>retrieve the data as appears on the text file but i wish to search and
match
>with the second field eg "Carr". If some one could help me with this code i
>would be most grateful as i have no clue what i am doing wrong. I have a
>copy of the source below

>Thank You in Advance for you answer

>Sean

>------------------------------------------------ source code
>Private Sub Command1_Click()
>Dim sid As String, pname As String, pop As Single, ar As Single
> sid = ""
>  pname = ""
>   Picture1.Cls
>If txtname.Text = "" Then
>    Font.Bold = True
>     Picture1.FontSize = 14
>      Picture1.Print Tab(3); "Please enter something"
>Else
>      If Option1.Value = True Then
>        Do While (sid <> txtname.Text) And (Not EOF(1))
>        Input #1, sid, pname, pop, ar
>         Picture1.Print sid, pname, pop, ar
>        Loop
>ElseIf Option2.Value = True Then
>          Do While (pname <> txtname.Text) And (Not EOF(1))
>          Input #1, sid, pname, pop, ar
>           Picture1.Print sid, pname, pop, ar
>Loop
>End If
>End If
>End Sub

>Private Sub Command2_Click()
>Picture1.Cls
>txtname.Text = ""
>txtname.SetFocus
>End Sub

>Private Sub Form_Load()
>Open "C:\windows\desktop\test\states.txt" For Input As #1
>Input #1, sid, pname, pop, ar
>End Sub



Thu, 26 Apr 2001 03:00:00 GMT  
 Searching a textfile - please help
@cts.com
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.0810.800
Newsgroups: microsoft.public.vb.syntax

If the format is consistent, try opening the text file as a comma
delaminated ASCII database. Or, if you have the option, just make it into a
database.

Greywolf Ghost


Quote:
>Hello,
>I am having trouble with my vb application, i am trying to search a text
>file and retrieve the data from it, for instance my text file has is set
out
>like this "NSW", "Carr", 23000000, 240900 The search will work the first
>time that the application is loaded but after that it will not work
>properly. I wish to have 2 differnet options using the option controls, the
>first option i wish to retrieve the data as it appears on the text file but
>i only want to match the first field eg "NSW", the second option i wish to
>retrieve the data as appears on the text file but i wish to search and
match
>with the second field eg "Carr". If some one could help me with this code i
>would be most grateful as i have no clue what i am doing wrong. I have a
>copy of the source below

>Thank You in Advance for you answer

>Sean

>------------------------------------------------ source code
>Private Sub Command1_Click()
>Dim sid As String, pname As String, pop As Single, ar As Single
> sid = ""
>  pname = ""
>   Picture1.Cls
>If txtname.Text = "" Then
>    Font.Bold = True
>     Picture1.FontSize = 14
>      Picture1.Print Tab(3); "Please enter something"
>Else
>      If Option1.Value = True Then
>        Do While (sid <> txtname.Text) And (Not EOF(1))
>        Input #1, sid, pname, pop, ar
>         Picture1.Print sid, pname, pop, ar
>        Loop
>ElseIf Option2.Value = True Then
>          Do While (pname <> txtname.Text) And (Not EOF(1))
>          Input #1, sid, pname, pop, ar
>           Picture1.Print sid, pname, pop, ar
>Loop
>End If
>End If
>End Sub

>Private Sub Command2_Click()
>Picture1.Cls
>txtname.Text = ""
>txtname.SetFocus
>End Sub

>Private Sub Form_Load()
>Open "C:\windows\desktop\test\states.txt" For Input As #1
>Input #1, sid, pname, pop, ar
>End Sub



Thu, 26 Apr 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

2. ----------HELP ME PLEASE:...How to edit a Textfile(datafile)?......------------

3. Microsoft Winsock Control and downloading Textfiles...Please help.

4. Please help:how can i count the number off lines in a textfile

5. Drag and drop textfile search?

6. search within textfiles

7. Searching textfiles for a string

8. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

9. search text in textfiles?

10. Search strings in textfiles

11. Search and replace in textfile

12. search within textfiles

 

 
Powered by phpBB® Forum Software