Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

Regular Expression HELP!

$
0
0
Hey all,

Am after a bit of help using regular expression.

I have 4 Text Boxes that i would like to validate before data is stored in database.

Code:

            If Not Regex.IsMatch(txtSaleID.Text, "(?s)^\d{6}$") Then
                MsgBox("Please enter a valid Sale ID (Numbers Only")
                txtSaleID.Select()
                Exit Sub
            End If

            If Not Regex.IsMatch(txtproductid.Text, "(?s)^(P)\d{6}$") Then
                MsgBox("Please enter a valid Product ID (Valid Product ID PXXXXXX)")
                txtproductid.Select()
                Exit Sub
            End If

            If Not Regex.IsMatch(txtqty.Text, "(?s)^\d$") Then
                MsgBox("Please enter a valid QTY (numbers only)")
                txtqty.Select()
                Exit Sub
            End If


            If Not Regex.IsMatch(txtcustomerid.Text, "(?s)^\d$") Then
                MsgBox("Please enter a valid Customer ID (numbers only)")
                txtqty.Select()
                Exit Sub
            End If

If i hit add with no values in the text boxes, the only error message that is displayed is the first one. How can i make it that the error is stored and displayed once all text boxes are checked?

Viewing all articles
Browse latest Browse all 27554

Trending Articles



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