How do I make a number Generator? Can somebody explain me? (with the code)
How to make a number generator?
Started by wazofski, Feb 29 2008 11:05 AM
13 replies to this topic
#1
Posted 29 February 2008 - 11:05 AM
|
|
|
#2
Posted 01 March 2008 - 06:37 AM
its pretty easy ok heres what you need a textbox and a command button
insert this code on the command button
thats all if you use a timer its more intereseting cuz you see how the numbers generat randomly :D
insert this code on the command button
Quote
text1.text = Rnd * 99999999999#
thats all if you use a timer its more intereseting cuz you see how the numbers generat randomly :D
#3
Posted 03 March 2008 - 02:37 PM
Quote
Dim random as New Random
dim num as integer
num=random.next(start Value, End value***)
me.xoutputlabel.text=num
dim num as integer
num=random.next(start Value, End value***)
me.xoutputlabel.text=num
***You must enter one more than what you want. So if you want a number from 1 to 100, the code would be
Quote
num=random.next(1,101)
#4
Posted 03 March 2008 - 02:45 PM
Great help guys. +rep given to you both.
I guess that wazofski can figure things out thanks to your help.
I guess that wazofski can figure things out thanks to your help.
#5
Posted 04 March 2008 - 08:19 AM
mm thx
#6
Posted 21 March 2008 - 04:49 AM
Thanks, i was wondering about that too. ^^
#7
Posted 02 April 2008 - 10:21 AM
I went a step further with this. If you want to have a user defined parameter for the generator to work within, then your code can look like this.
I've always love tweaking code some. Don't mind the comments, i do it so i don't lose myself (as I have ADD and find that it happens a lot). Hope it helps you further your project a little more, or helps someone with maybe that question.
Dim random As New Random
Dim num As Integer
'declare the the user input variables
Dim start As Integer
Dim finish As Integer
start = Val(Me.value1Txt.Text)
finish = Val(Me.value2Txt.Text) + 1
'randomly generat a number withing the user defined parameters
num = random.Next(start, finish)
'display output
Me.resultLbl.Text = num
I've always love tweaking code some. Don't mind the comments, i do it so i don't lose myself (as I have ADD and find that it happens a lot). Hope it helps you further your project a little more, or helps someone with maybe that question.
#8
Posted 03 April 2008 - 01:35 PM
Hmm my VB shows me an error in this line
It does not accept As New Random (There is no Random in my list)
Dim random As New Random
It does not accept As New Random (There is no Random in my list)
#9
Posted 04 April 2008 - 06:15 AM
I'm not exactly sure why it is doing that for you, it seems to be working fine for me. Are you having it run the code inside the event handler, or are you running the code at the start of the program?
#10
Posted 04 April 2008 - 07:07 AM
What do you mean? I made that code in the form_load
#11
Posted 06 April 2008 - 10:57 AM
It works for me if the code is run inside an event handler such as the clicking of a button, i'm not sure exactly why yours isn't working, i will run some tests when i get home later today and do some troubleshooting and see if maybe I can come up with a solution.
#12
Posted 07 April 2008 - 08:47 AM


Sign In
Create Account


Back to top









