Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to make and acsess a database for later use.

Status
Not open for further replies.

DarkMercenary44

Technical User
May 19, 2000
55
US
I'm making a movie rental program for a friend.&nbsp;&nbsp;I need the program to save the movies, descriptions, movie numbers to a file.&nbsp;&nbsp;Then I want to have an option to search the file for a string that macthes, like the number of the movies, and have it find the string, then find the record number of that string , and then acsess all variables of that record and display them for him.<br>Do I use an array for this, an random acsess file [using a userdefined type or what ] <br>I know how to acsess the file, and get a variable from it, but I can't figure out how to get Qbasic to find the line number that the variable that I search for are stored in.&nbsp;&nbsp;Please help!
 
Question:&nbsp;&nbsp;&nbsp;I know how to acsess the file, and get a variable from it, but I can't figure out how to get Qbasic to find the line number that the variable that I search for are stored in.<br><br>Answer:&nbsp;&nbsp;You need to put in a counting routine within the searching routine...<br><br>Eample:<br><br>DO WHILE 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color=red>LineCounter = LineCounter +1</font><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LINE INPUT 1, ReadLine$<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;IF INSTR(ReadLine$, Word2Search$) &gt; 1 THEN EXIT DO<br>LOOP<br>PRINT &quot;Word to search: &quot;; Word2Search$<br><font color=red>PRINT &quot;Located in line: &quot;; LineCounter</font><br>PRINT &quot;Line reads as follows... &quot;; ReadLine$<br><br><b>NOTE 1:</b> if searching for a variable in a fixed-length file (User Defined) then the counting variable, you should be using, will indicate the &quot;record&quot; number for which the data is stored in.<br><br><b>NOTE 2:</b> If searching for a variable in a mixed-length file (NOT Defined) then the counting variable, you should be using, will indicate the &quot;line&quot; number for which the data is stored in.<br><br>Hope this helps.&nbsp;&nbsp;:cool: <p> <br><a href=mailto: > </a><br><a href= > </a><br>Programming knowledge: BATch processing, QuickBASIC 4.5, dBASE III+, Visual Basic 4, Excel Macro writing (ver 95 & 97)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top