|
-
Sep 6th, 2000, 09:09 PM
#1
Hello all,
i was just making a program to randomly create funny names for players in a game where the npc's are always named different. i got some dictionaries, but i don't have any idea about the code. any and all help would be appreciated.
-
Sep 6th, 2000, 09:22 PM
#2
Here is the code to randomize a list of names:
Code:
Private Sub Command1_Click()
Randomize
iName = Int((5 * Rnd) + 1)
If iName = 1 Then iReturn = "Name1"
If iName = 2 Then iReturn = "Name2"
If iName = 3 Then iReturn = "Name3"
If iName = 4 Then iReturn = "Name4"
If iName = 5 Then iReturn = "Name5"
iName = iReturn
Msgbox iName
End Sub
Hope that helps.
-
Sep 6th, 2000, 09:25 PM
#3
ok,
hey,
that was fast!
but anyway, thanks for the help, but im looking for more of a reading a dictionary .txt file instead of having to enter them in there manually. is there any way that exists that i could do that?
-
Sep 6th, 2000, 09:37 PM
#4
Well, if it's in a text file, than you can load them all into a listbox and randomize them from there.
Code:
Open "C:\names.txt" For Input As #1
List1.AddItem Input$(LOF(1), 1)
Close #1
And to randomly choose a name on the list:
Code:
Function randomnumber(finished)
Randomize
randomnumber = Int((Val(finished) * Rnd) + 1)
End Function
Private Sub Command1_Click()
On Error Resume Next
i = randomnumber(List1.ListCount)
List1.ListIndex = i
End Sub
-
Sep 6th, 2000, 09:56 PM
#5
ok,
thanks, but i just need some help on finding the 'listbox' button.
-
Sep 6th, 2000, 10:01 PM
#6
Ok, if you have vb6, open it, create a standard exe, and look to the left for a toolbar. Drag your mouse over the items and it will tell you what they are. Double Click CommandButton and ListBox. And you should be able to continue with the code I gave.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|