Checking text fields

durilai

Member
Joined
Oct 17, 2005
Messages
16
Programming Experience
1-3
I have a form with two text fields.

1. Is used to enter a number and locate that number in a table

2. Is used to enter a name to search

On the first one they enter an ID, the ID is given to them like: A000123
But the actual ID is only 123, so I want to trim anything before first legitamite number, which would be all letters and anynumbers smaller than 1.

On the second, the search works fine, but if there is no results my app stops without any errors. How can I prevent this. I tried checking to see if there were rows and then print a msg box and that worked but when I hit ok the app still closed.

Any help would be great
 
Not sure on the second one, would need to see some code.

Here is my thought on the first:

VB.NET:
Private Function GetPartNumber(ByVal strSource As String) As Integer

        Dim chrDigit As Char
        Dim intStringCounter As Integer
        Dim strTemporaryNumber As String

        For intStringCounter = 0 To strSource.Length - 1

            ' look at a single character
            chrDigit = strSource.Substring(intStringCounter, 1)

            ' First determine if it is a number
            If Char.IsDigit(chrDigit) Then
                strTemporaryNumber &= chrDigit.ToString
            End If

        Next

        ' Return strTempoaryNumber after it is Parsed into an Integer
        Return Integer.Parse(strTemporaryNumber)
    End Function
 
Back
Top