Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Random Generate


Reply
 
Thread Tools Display Modes
  #1  
Old 11-12-2003, 01:20 PM
slash85 slash85 is offline
Newcomer
 
Join Date: Nov 2003
Posts: 3
Unhappy Random Generate


Hi,

I'm tryin to write a little program that generates names i have got 2 .txt files the 1st contains first names 2nd contains surnames, i want the program 2 take random first names and merge them with random surnames and export the results into another txt file, is this possible can any1 help me out ?

Thanks in Advance
Slash
Reply With Quote
  #2  
Old 11-12-2003, 01:24 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

Read all of the names in the file and store them in an array. This will enable you to generate a random name (after you've generated the random number of course) by referencing the array member that matches the random number you created.
Have you worked with arrays before?
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #3  
Old 11-12-2003, 01:27 PM
slash85 slash85 is offline
Newcomer
 
Join Date: Nov 2003
Posts: 3
Default

Nope i'm a newbie, thanks for the quick reply can you give me a little more detail?
Reply With Quote
  #4  
Old 11-12-2003, 01:33 PM
Iceplug's Avatar
Iceplug Iceplug is offline
MetaCenturion

Retired Moderator
* Guru *
 
Join Date: Aug 2001
Location: California, USA
Posts: 16,583
Default

Um... you may want to learn more about arrays and file access before attempting something like this.
Code:
Private Sub Form_Click() Dim Xnames(0 To 9) As String, R as Integer Xnames(0) = "Rover" Xnames(1) = "Fido" Xnames(2) = "Bowwow" Xnames(3) = "Doggy" MsgBox Xnames(1) 'For loop sets all array elements For R = 0 To 9 Xnames(R) = "Meow Mix" Next MsgBox Xnames(1) 'Childs Play mathematics R = 8 + 2 * 4 - 3 * 5 Xnames(R) = "Iceplug" MsgBox Xnames(1)
__________________

Iceplug, USN
Quadrill 1 Quadrill 2 (full) Quadrill 3 JumpCross .NET Website is ALIVE! - DL Platform Tour for VB.NET! Posting Guidelines Hint: Specify your location in your user cp profile if you want compassion!
Reply With Quote
  #5  
Old 11-12-2003, 01:57 PM
slash85 slash85 is offline
Newcomer
 
Join Date: Nov 2003
Posts: 3
Default

just tried that little bit of code you sent wen i click it says compile error: expected end sub???????
Reply With Quote
  #6  
Old 11-12-2003, 02:41 PM
zanth_quareni's Avatar
zanth_quareni zanth_quareni is offline
Senior Contributor
 
Join Date: Aug 2003
Location: Tomarria
Posts: 905
Default

Quote:
Originally Posted by slash85
just tried that little bit of code you sent wen i click it says compile error: expected end sub???????


Put an End Sub on the end of that and it will work.

For reading in the names, do something like this:
Code:
dim Fornames$(), Surnames$() dim fullName$ dim i%, j% redim fornames(0) redim surnames(0) Open "C:\forname.txt" for input as #1 do until eof(1) redim preserve Fornames(ubound(Fornames)+1) input #1, Fornames(ubound(Fornames)) loop close #1 'now do the same for surnames i=int(rnd * (ubound(fornames)-1)) j=int(rnd * (ubound(surnames)-1)) fullName = fornames(i) & " " & surnames(j) msgbox fullName
Something like that should get you started, didn't test but should work.
__________________
...leben ohne sinn...
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Random Numbers BillSoo Tutors' Corner 9 09-09-2006 12:45 PM
Long random number generation loquin Code Library 0 05-01-2003 04:45 PM
Generate Random Numbers And Write Them To A File Sebastian Mares General 7 11-14-2002 01:24 PM
Generate a Random String of Characters... Burnard General 5 05-20-2002 05:07 AM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->