Michael3455
Active Member
- Joined
- Sep 11, 2005
- Sythe Gold
- 0
- Messages
- 134
EDIT... One problem fixed, another pops up... Eeeek.
Ok, well. The problem that I thought I had wasn't the problem that I had. I don't think. Because I was getting annoyed that I could never pick the number, I decided to look into it by placing a msgbox(randnum) after the if statements to see what the random number was each time. The results I got freaked me out.
They changed every goddamn time! That's not a good thing. So, I'm gonna try to fix it up but I don't have a clue how to. I've got to figure out a way to get the random number to go into the variable randnum, but then stop changing.
Also, if someone with a reasonably ammount of experience in programming and vb.net could comment on my code, tell me if I've done everything in the standard/best way. Also, is the if /ifelse statements the best way to do this?
Ok, well. The problem that I thought I had wasn't the problem that I had. I don't think. Because I was getting annoyed that I could never pick the number, I decided to look into it by placing a msgbox(randnum) after the if statements to see what the random number was each time. The results I got freaked me out.
They changed every goddamn time! That's not a good thing. So, I'm gonna try to fix it up but I don't have a clue how to. I've got to figure out a way to get the random number to go into the variable randnum, but then stop changing.
Also, if someone with a reasonably ammount of experience in programming and vb.net could comment on my code, tell me if I've done everything in the standard/best way. Also, is the if /ifelse statements the best way to do this?
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object_
, ByVal e As System.EventArgs) Handles Button1.Click
Dim answer As Integer
Dim theRandomGen As New Random()
Dim randnum = int (RND() * (1 - 100 + 1)) + 100
answer = TextBox1.Text
If answer = Randnum Then
MsgBox("You got it right!")
ElseIf answer > Randnum Then
MsgBox("Too high!")
ElseIf answer < Randnum Then
MsgBox("Too low")
End If
Msgbox(randnum)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object_
, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class




