Flash Games

 FAQ   Search   Members   Groups   User Control Panel      Login 

It is currently Thu Jan 08, 2009 3:32 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Text Files
PostPosted: Sun Jul 13, 2008 7:58 pm 
Offline

Joined: Sun Jul 13, 2008 7:43 pm
Posts: 0
Hi all,

I'm new to VB 2008 Express (I could help myself in VB6) but everything seems so complicated, so I would appreciate some help.

I want to read random lines from a file into an array (I can do that fine), but I want ALL the lines in random order, so I was thinking of generating my random number (1-300, for example), but when I get to 299, how long is it going to take to "trigger" 300 (or whatever number is left)???

So I was thinking that the best is to read line random(x) and then delete that line from the file, and then do a random(1-299) and so on. How would I write these lines into another file then (new file).

If anyone could give me some sample code I would appreciate it, and any links to text-file handling would also be welcome.

Thanx


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 24, 2008 8:27 am 
Offline

Joined: Sun Aug 17, 2008 1:40 pm
Posts: 4
Location: Hyderabad, INDIA
We are on VB6. We use following function to randomly assign numbers in a arry and then proceed as our requirement.Here M is a one dimensional array of no of entries you would like to have in your file. intially every entry is 0. as the randl\om nos are generated they are posted in respective cells, and if the gnerated no is already assigned then anohter no is generated and so on.

the procedure is quite fast and can populate 1000 nos within miliseconds, and 20000 nos also within a second.

Sub GENRATE(M%())
Randomize Timer
nk% = UBound(M, 1): MM% = 1
Do: l% = Int(Rnd(1) * nk) + 1
If M(l) = 0 Then M(l) = MM: MM = MM + 1
Loop While MM <= nk
End Sub

Once this array is with you, then you can incorpote it with your data lines and thereafter sort them on these numbers to radomize your data.

_________________
Windostat your own way of computing statistics


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review

Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User:
Pass:
Log me on automatically each visit: