Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

Help with Validating A Number....

$
0
0

I have the code below where I need to validate that the random number - Be sure itdoes not exist in the database.

If the number exist the code should regenerate a new number and validate it until a number comes up that does not exist in the database....

GOAL:

Please help me fix my code -- There must be a more efficient way of validating a random number - Please share your expertise - thank you much....  The random number can only exist once in the database.

'Create RandomNumber

Dim RandomClass As New Random()
Dim RandomNumber As Integer
RandomNumber = RandomClass.Next(1, 99999)

'Send RandomNumber to Class for validation
Dim CheckNum As New Call_Class
CheckNum.CheckProVendID(RandomNumber)

        If CheckNum.ErrorFlag Then
            lblErrorMsg.Text = CheckNum.ErrorMessage  -- assume no error found
        Else

           'This is where I need to check any RandomNumber generated in the database.

            If CheckNum.RecNo > 0 And CheckNum.Prospect_VendorID = RandomNumber Then
                Dim NewRandomNumber As Integer = RandomClass.Next(1, 99999)
               Generate new number and validate it to be sure no pre-existing Number exist.
               Once no match is found assign value
            Else

                No RandomNumber match found -- assign value.
                lblVendorNumber1.Visible = True
                lblVendorNumber2.Text = RandomNumber
            End If
        End If


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>