问题
I am trying to generate a random number and display it using a label. This is my code:
Dim Random As Integer
Random = Int((3 * Rnd) + 1)
Label108.Caption = Random
Why is my label not changing to a random number between 1 & 3
UPDATED AS PER QUESTION IN COMMENTS
Private Sub Form_Load()
Dim Random As Integer
Random = Int((3 * Rnd) + 1)
Label108.Caption = Random
Label8.Caption = Format(Date, "dddd dd mmmm yyyy")
Label14.Caption = Environ("username")
回答1:
The value of Random is changing between 1 and 3, you can see by running this,
Dim Random As Integer
Random = Int((3 * Rnd) + 1)
MsgBox Random
This issue is with Label108.Caption = Random, i'm not sure what this line is doing?
来源:https://stackoverflow.com/questions/40239356/generate-random-number-vba