You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

natch

Beginner

  • "natch" started this thread

Posts: 11

Date of registration: Jul 27th 2009

  • Send private message

1

Monday, November 2nd 2009, 12:44am

Random / Rnd()

I investigated in the Internet as it will produce a random number in the VB6, I found the rnd (), I used the rnd and random, but always it was producing a very big number ' Double ', i wanted that it was producing a whole number...
How to do that in the jabaco?

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Monday, November 2nd 2009, 10:18am

Hi natch,

the MSDN does help you, read this article:
http://msdn.microsoft.com/en-us/library/f7s023d2(VS.80).aspx
or have a short look:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Public Sub Command1_Click()
   
   Dim d As Double
   
   'The Rnd function returns a value less than 1, but greater than or equal to zero
   d = Rnd()
      
   MsgBox CStr(d)
   
End Sub
Public Sub Command2_Click()
   Dim i As Integer
   
   i = randomvalue(50, 100)
   
   MsgBox CStr(i)
   
End Sub
Function randomvalue(lowerbound As Integer, upperbound As Integer) As Integer
   randomvalue  = CInt(Int((upperbound - lowerbound + 1) * Rnd() + lowerbound))
End Function




regards

OlimilO

natch

Beginner

  • "natch" started this thread

Posts: 11

Date of registration: Jul 27th 2009

  • Send private message

3

Wednesday, November 4th 2009, 1:32am

thanks ...

I already know how to do this in a few lines of code, easier

Source code

1
2
3
4
5
6
7
8
Public Sub Command1_Click()   

Dim a As Long   'returns an integer value

   a=Rnd()*9   'returns an integer value
   MsgBox (a)
   
End Sub

I do not know if it gets better ...

Rate this thread
WoltLab Burning Board