Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 10-16-2004, 03:26 PM   #1
Member (7 bit)
 
Join Date: Oct 2003
Posts: 83
Vb Save Files

It is not a school project but for someone else. How could I use random numbers to bring up certain items in a text file that I already saved.
shadowspy1 is offline   Reply With Quote
Old 10-18-2004, 12:25 PM   #2
Come in Ray...
 
faulkner132's Avatar
 
Join Date: Sep 2004
Posts: 1,668
After you have generated a random number, you could use the following to go to that line in the text file. This is in VB6.

Code:
Dim strData As String
Dim intCount As Integer
intCount = 0

Open "c:\filename.txt" For Input As #1
While Not EOF(1) And intCount <> RandomNumber
   LineInput #1, strData
   intCount = intCount + 1
Wend

If intCount <> RandomNumber Then
   Msgbox "End of data reached."
Else
   Msgbox "The data on line " & RandomNumber & " is: " & strData
End If
faulkner132 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 06:55 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2