FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Visual Basic My randoized Code





Ablank
This comde is to get a random number!!!!
Or eventes...use imagination Very Happy

Creat a command button!!
And add this code!
Code here:

Code:
Private Sub Command1_Click()
Randomize

numGerado = CInt(Rnd * 10)

MsgBox numGerado
End Sub


In this code if you press the comand button, the Visual beginner's all-purpose symbolic instruction code shows one msgbox with it numbers of generated 1 to 10!

Sorry my bad English Sad
gaudi
here is a funktion which one uses the Date-Time so you never have
the same random number

Public Function GenerateRandom(minVal As Long, maxVal As Long) As Long
Dim intr%
intr = -1
maxVal = maxVal + 1
If maxVal > 0 Then
If minVal >= maxVal Then
minVal = 0
End If
Else
minVal = 0
maxVal = 10
End If
Randomize (DatePart("s", Now) + DatePart("m", Now))
Do While (intr < minVal Or intr = maxVal)
intr = CLng(Rnd() * maxVal)
Loop
GenerateRandom = intr
End Function
Teddy1
Sweet commands guys. Great work Smile. Keep it up Cool
Related topics
Microsoft Visual Basic help
C#,Visual Basic.NET,Visual Studio.NET Videos
visual basic.net
MS Visual Basic Studio 2005 Express Edition
Visual Basic Tutorial - File I/O in VB: Text Files
Visual Basic Tutorial - Control Arrays: What, Why and How
Visual Basic Tutorial - Looping
Visual Basic Express Addition
Visual Basic programming tutorial
how about security of visual basic 6.0??
VB Help for those who need small pointers in Visual Basic
visual basic
VB 6 problem executing a .exe program via a visual basic app
Visual Basic Build Problem
Visual Basic RUles
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.