Doing this in Visual Basic is slightly more inviolved:
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Randomize()
Dim moneyMade = Int(5 * Rnd() + 5)
MsgBox(moneyMade)
End Sub
End Class
In this example, this is being done in a
Button1 click event. Note here that the
Randomize() subroutine is first executed; this is required to randomised the integer values returned, for further information see:
Randomize Function (Visual Basic).
Next, we declare a new variable and the
Int() function returns an
integer-portion of a number (i.e. getting rid of any decimal places etc).
The
5 * Rnd() + 5 ensures that what is returned is between 5 and 10. The
Rnd() returns between 0 and 0.99 (i.e. less than 1 but more than or equal to 0). For more information on
Rnd() see:
Rnd Function (Visual Basic)
Hope this helps.