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.
Printable View
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.
Here is the code to randomize a list of names:
Hope that helps.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
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?
Well, if it's in a text file, than you can load them all into a listbox and randomize them from there.
And to randomly choose a name on the list:Code:Open "C:\names.txt" For Input As #1
List1.AddItem Input$(LOF(1), 1)
Close #1
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
ok,
thanks, but i just need some help on finding the 'listbox' button.
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.