Results 1 to 9 of 9

Thread: Phone number validate

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2001
    Location
    Gold Coast, Australia
    Posts
    7

    Exclamation HELP! Stuck on phone number validate

    Hello people,

    I am in the process of writing my major Yr 12 visual basic case study, and have run into a little problem. I am trying to check that when the txtPhone_Num field loses focus a sub will check 1 digit at a time to make sure that only numbers have been entered.

    Anyway this is what i've got so far:

    Private Sub txtPhone_Num_LostFocus()
    If txtPhone_Num.Text <> "" Then
    Phone_NumValidate
    End If
    End Sub

    Private Sub Phone_NumValidate()
    Dim i As Integer, char As String * 1, sentence As String
    sentence = txtPhone_Num
    i = 1
    For i = 1 To Len(sentence)
    char = Mid(sentence, i, 1)
    If char <> "1" Or "2" Or "3" Or "4" Or "5" Or "6" Or "7" Or "8" Or "9" Or "0" Then
    intpress = MsgBox("Please enter a valid phone number containing numbers only", vbExclamation + vbOKOnly, "Error!")
    txtPhone_Num = ""
    txtPhone_Num.SetFocus
    Exit Sub
    End If
    i = i + 1
    Next i
    End Sub


    Anyway the problem is that the error comes up every time, even when i do just put numbers in. Can anyone their help?

    Thanks.[PHP]
    Last edited by sponger58; Jun 10th, 2001 at 12:53 AM.

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