Input# and Line Input# 
Author Message
 Input# and Line Input#

Hello, Troy.

If you know the string you want to retrieve, you can open the file
as Line Input, and search each line for your string. There are
a number of ways of searchiing for your string. The way I am used
to doing this string-handling:

Dim FindWhat1 As String
Dim FindLen1 As Integer
FindLen1 = Len(FindWhat1)
Dim Msg1 As String
Dim FNum As Integer
FNum = FreeFile
FindWhat1 = "This is the string I am looking for"
fname = "c:\files\x.dat"
Open fname For Input As #(FNum)
Do While Not EOF(FNum)
        Line Input #(FNum), Char
        Msg1 = Left$(Char, FindLen1)    'The left-most characters, of
the
                                        'length you are looking for.
        If FindWhat1 = Msg1 Then
                'A Match. Msg1 becomes your variable
                MyVariable = Msg1
        End If
Loop
Close #(FNum)

This procedure always looks at the cascading ASCII text, in this case,
those characters always to the left of each line. You can easily change
this arrangement to right, or even character by character, rather than
line by line. You can increment a number for each line, and mark its
location that way. I hope this is what you were asking.

Regards,
David

Quote:

> I have been able to create a data file with the Open "x.dat" For Append
> as vFileNum using a print # command to write to the data file and using
> the old Input LOF concept I can get the entire contents of the file read
> from the data file. I am not, however, able to read just one item. I've
> tried changing the print command to Write # and use Input. Ive also
> tried Line INput# but no matter what filenumber I use, I always get the
> first string in the list returned. How can I get any string in the list
> returned to a variable?



Sun, 20 Jun 1999 03:00:00 GMT  
 Input# and Line Input#

?
? I have been able to create a data file with the Open ?x.dat? For
Append
? as vFileNum using a print # command to write to the data file and
using
? the old Input LOF concept I can get the entire contents of the file
read
? from the data file. I am not, however, able to read just one item.
I've
? tried changing the print command to Write # and use Input. Ive also
? tried Line INput# but no matter what filenumber I use, I always get
the
? first string in the list returned. How can I get any string in the
list
? returned to a variable?

Hi Troy,
I presume what you are wanting to do is :-
read record 15 then 10 then 25 then 2 then 9 etc

In this case you will need to look at Random records in the help section
but basically you specify the length of each record and then in your
code
you can actually specify which line to jump to.

I know this doesn't make much sense but after reading the help screens
hopefully it will.
--
Regards



Sat, 26 Jun 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. code similar to Qbasic INPUT and LINE INPUT keywords

2. Using Line Input to go back a line

3. line input lines greater than 255 characters?

4. reading input line by line

5. vba line input not recognizing end of line

6. input for input (2)

7. **Need Help with User INPUT, ASCII Codes, INPUT String length

8. Formatting date input in Input Box

9. Input vs Input$

10. Help: INPUT / INPUT # for gopher/UNIX files

11. API Call - Minimized App To Test Input of Mouse And Key Input

12. how to detect how long without any input since last input action

 

 
Powered by phpBB® Forum Software