I am looking for suggestions on a better way (one that works).... with the following code. All works great but the red colored part. I have tried diffrent versions of it but I still struggle. Is there a way to use more than one If....Then....Else statement in the same sub? or is there a more convenient way to throw diffrent error messages depending on the type of condition not met.
For those that may question this.... TextBox2.Text must be a greater value than TextBox1.Text
Code:Dim Rng1 = TextBox1.Text Dim Rng2 = TextBox2.Text Dim Rand As New System.Random(Now.Millisecond) If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox1.Text = "0" Or TextBox2.Text = "0" Then MessageBox.Show("Range must be positive numbers!", "Input Error") ElseIf TextBox1.Text <= TextBox2.Text Then MessageBox.Show(TextBox2.Text & "is less than" & TextBox1.Text, "Range Error") Else Label1.Text = Rand.Next(Rng1, Rng2 + 1) End If




Reply With Quote