I'm new at vba so I'm starting with examples I find and things like that.
Now I'm trying to do an example i found on internet which is about a game where you have to guess a random number.
My game is based on 3 columns and 2 buttons.
In 1st column "Nº introducido" I want that appears the number that user introduced in an inputbox,
in 2nd column "Situación" I want that programm tells teh user if the random number is greater, smaller or equal to the number he introduced
and the 3st column "Intentos" must appears the number of attemps the user needed.
All this must happen when I press the "Jugar" button but this enters an infinite loop, I even commented blocks of code to know where was the problem and I cant find it. The most extrange is I'm using the same code than in the example.
This is my piece of code:
Private Sub CommandButton2_Click()
Dim aleatorio, minum, fila As Integer
aleatorio = Math.Round(Math.Rnd * 100)
Debug.Print aleatorio
While aleatorio <> minum
minum = InputBox("Introduce un nº entre 1 y 100", "", , 150, 150)
' Range("c22").Offset(fila, 0).Value = minum
'
' If aleatorio > minum Then
' MsgBox "El nº es más alto"
' ElseIf aleatorio < minum Then
' MsgBox "El nº es más bajo"
' Else
' MsgBox "Correcto"
' End If
Wend
End Sub
I'm using a debug.print to know the random number and I'm trying to put the same number that appears but the inputbox never is closed.