kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
I have this function to randomly generate certain numbers. Then I am calling for its verification with another Sub. And display an alert. Then I found out that if there is a match, instead of the alert showing me the value for the match, it goes on to generate a new set of numbers from the random function.
The verification code
The randomly generated code
Now what I need is to maintain the same variable value used for the if statement as the MsgBox alert.
Can someone pull it out for me?
The verification code
Code:
Sub TestMatch ()
If ReturnPin Mod 1111 = 0 Then
MsgBox ReturnPin
End If
End Sub
The randomly generated code
Code:
Function ReturnPin() As String
Dim i As Integer, i2 As Integer
Randomize
i = Rnd * 10
i2 = Rnd * 9
Select Case i
Case 10
i = Rnd * 6
ReturnPin = i & i + 1 & i + 2 & i + 3
Case Else
ReturnPin = i & i & i2 & i2
End Select
End Function
Now what I need is to maintain the same variable value used for the if statement as the MsgBox alert.
Can someone pull it out for me?