![visual basic random number visual basic random number](https://i1.wp.com/datatalk.pl/wp-content/uploads/2017/11/funkcje_vba_excel_rnd.png)
IntCounter = intCounter + 1 'increments the counter for the next guess MsgBox("Please enter a number between 1 and 25!", Title:="Oops!") 'error if a user enters a number greater than 25 MsgBox("Guess Lower!", Title:="Guess Lower!")
![visual basic random number visual basic random number](https://i.ytimg.com/vi/CBqdh6bY5WY/maxresdefault.jpg)
The random integer is" + intRandNum) 'should display the random number in the message box w/ a correct guess Private Sub btnGuess_Click(sender As Object, e As EventArgs) Handles btnGuess.ClickÄo Until intCounter = 5 'Only 5 guesses allowed MsgBox("Click the New button to start the game!") Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load Private intRandNum As Integer = randGen.Next(1, 26)
Visual basic random number code#
This is the first time I've ever posted any code on Reddit.
![visual basic random number visual basic random number](https://d2vlcm61l7u1fs.cloudfront.net/media%2F6a1%2F6a17a7e7-355a-4b59-b65d-fe4f0f212d90%2FphpcAlaoB.png)
Also, I apologize if it isn't formatted the same. Any help cleaning this up would be appreciated. Otherwise, it gets stuck in the loop after one guess. However, this only works if I remove the loop. The program generates the random numbers and I can make guesses and it tells me which direction (up or down) I need to go.