Results 1 to 4 of 4

Thread: Validation problem [Resolved]

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    127

    Validation problem [Resolved]

    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
    Last edited by teamdad; Jun 17th, 2004 at 08:48 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width