I need to make a program that will tell me if the user entered a vaild email, phone number, or social security number. This is what I have so far.

Sub Main()
    Dim num As String
    num = InputBox("Please enter your number!!!", "What was the number you were given?")
    MsgBox(num)
    If num Like "###-###-####" Then
        MsgBox(num & " is a phone number")
    ElseIf num Like "###-##-####" Then
        MsgBox(num & " is a social security number")
    ElseIf num Like "#####@###.###" Then
        MsgBox(num & " is a email")
    Else
        MsgBox(num & " is not a valid phone number, social security number, or email address.")

    End If

Try this:

 Sub Main()
        Dim num As String

        num = InputBox("Please enter your number!!!", "What was the number you were given?").ToString()
        Dim len As Integer = num.Length()
        ' use not because isnumeric returns a 0 if the input is numeric which is a BOOL FALSE

        If (len = 12) Then
            If (Not (IsNumeric(num.Substring(0, 3)) And (num.Substring(3) = "-") And (Not (IsNumeric(num.Substring(4, 3)))) And (num.Substring(7) = "-") _
            And (Not (IsNumeric(num.Substring(8, 4)))))) Then


                MsgBox("You input a Phone number: " & num, MsgBoxStyle.Information, "Congratulations")

            End If

        End If

        If (len = 11) Then

            If (Not (IsNumeric(num.Substring(0, 3)) And (num.Substring(3) = "-") And (Not (IsNumeric(num.Substring(4, 2)))) And (num.Substring(6) = "-") _
            And (Not (IsNumeric(num.Substring(7, 4)))))) Then

                MsgBox("You input a SSN number: " & num, MsgBoxStyle.Information, "Congratulations")

            End If

        End If

        If (len = 13) Then
            If (((num(5) = "@") And (num(9) = ".") And (Not IsNumeric(num.Substring(10, 3))))) Then

                MsgBox("You input an E-mail address: " & num, MsgBoxStyle.Information, "Congratuations")

            End If

        End If

        If (len > 13 Or len < 11) Then
            MsgBox("Invalid input detected: " & num, MsgBoxStyle.Critical, "Sorry")
        Else
            ' the default statment
            MsgBox("Invalid input detected: " & num, MsgBoxStyle.Critical, "Sorry")

        End If

    End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.