Hi
I want to make a txtbox where a number between 1 to 456 to apear continuously, until I press a button.
Could you help me with an exemple?
Thanks and best regards
Printable View
Hi
I want to make a txtbox where a number between 1 to 456 to apear continuously, until I press a button.
Could you help me with an exemple?
Thanks and best regards
There are at least 100,000,000 ways to do this, here is one.
Create a project with 1 Form
add two buttons and a timer
Set timer property:
enabled = False
interval = 1000
Set Command1:
Caption = &Start
Set Command2:
Caption = Sto&p
In the code paste:
Hope this helpsCode:Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim z As Integer
z = Int((Rnd * 456) + 1)
If z <= 456 Then
Text1.Text = z
End If
End Sub
Newtonberry.com
Thanks, but I want to do a number (in txtxbox or label) which it is changes continuu until I press the button.
I want to make this for draw a winer, because the number represent a customer bil...
Thanks in advance
Did you try the example posted by Newtonberry?
His code works just fine for me.
Thanks, the code is OK, but I have a lot a problems...Now, I understand that I have a lot of customer bils and each bil has a number which can be 2345, 2346 or 2399, 3278. So, here is my problem, there are not consecutive numbers.
I try to make 4 labels, in each of them to apear a digit number (eg. 2,3,4,5), I place 4 Timer on form, and I got stuck...
Well, I think there is 2 ways to solve this:
-to put the numbers in a table and when I press the button each number must be split in 4 digit number...
-to rule continuu all the number in a same textbox or label and when I press button the numbers stop. I don't know how can I do this, please give me a help.
Thanks
I'm not exactly sure what your asking but maybe this will help.
In the above code Rnd is a Random number. We multiply that number by our upper limit number 456. Then we add 1, this is our lower limit. Not exactly what happens but close enough.Code:Private Sub Timer1_Timer()
Dim z As Integer
z = Int((Rnd * 456) + 1)
If z <= 456 Then
Text1.Text = z
End If
End Sub
Then we check that our number isn't above 456, because 456+1=457 we don't want that. "Yes, had we put 455 as our multiplier that would had solved that.
So if we want single digit numbers we just change 456 to 8. Then our example would give numbers 1-9. If we take out our +1 from the function we get 0-9.
Hope that isn't confusing.
Thanks, now is better...Your descriptions help me more, thanks again!