I'm trying to get a list from a doc file i have made using QB, but it just scrolls past the screen, i want 22 listed in a box then when the user presses a key it will show 22 more and so on till it reaches the EOF.
In the Doc i have only two entries, i.e.
Name, Address
but there is over a hundred files
How do i do this, please
HI Champion, one way you can do this is with a loop within a loop....for example.
Code:
DIM WorkString AS STRING
DIM Counter AS LONG
OPEN "DocFile.Ext" FOR INPUT AS #1
DO WHILE NOT EOF(1)
FOR Counter = 1 to 22
LINE INPUT #1, WorkString
PRINT WorkString
IF EOF(1) THEN
EXIT FOR
END IF
NEXT Counter
INPUT "Press a key for next 22 items.", A$
CLS
LOOP
Something like this would do what you need.fairly easily.
I used to do it in a single line. Don't know why you all call me an untidy programmer
Code:
cnt=0 'not needed actually
while not EOF(1)
line input #1,a$
print a$;
cnt=cnt+1:if cnt=22 then cnt=0:b$=input$(1)
wend
My next problem is that i would like to be able to search the doc file for a particular entry, how do i do this
If the entry you search for is never splitted between two lines it's easy
Code:
b$="String to find"
found=0
cnt=0
while (not eof(1)) and (found=0)
line input #1 ,a$
cnt=cnt+1
found= instr(a$,b$)
wend
if found then
print "String ";b$;" found at line ";cnt;" position ";found
else
print "String ";b$;" not found"
end if
Antoni,
I'm glad to see your updated avitar...your old one with the elegant-looking whatever-it-was was cool...and I like knowing what you look like. However, ......now that I KNOW what you look like, (and please know...you look fine)....I prefer the elegant-looking-cartoon-whatever-it-was that you used to display. It was fun, light, and...you. The current one is so....well....realistic.
Anyway, I'm an irregular contributor and hope I don't get banned for the comment...you *ARE* a strong and respected voice on this forum.
Cheers,
Joe
Quote:The current one is so....well....realistic.
Hehe.. thats a nice way of saying you're ugly
Ya, I'm joking.