I have this sub routine that validates a phone number. Everything works(i think) until i get to the instr. The purpose of the instr is to flag an error if the user puts a "-" in the string. Now I have two questions. One if I am checking to see if it isnumeric, shouldn't the "-" produce a flag. Secondly, why doesn't the instr flag the "-", its not a special character of some sort, is it.
fvalue=123-444-23
Sub Check_Phone(fvalue,dname)
If len(Trim(fvalue))=0 Then
ErrCount=ErrCount+1
AddErr(Cstr(ErrCount) + ". "+ dname+ " cannot be empty"
else
If IsNumeric(Trim(fvalue))=False Then
ErrCount=ErrCount+1
AddErr(CStr(ErrCount) + ". " + dname + " is not a valid Number"
else
if len(CStr(fvalue)) < 10 then
ErrCount=Errcount+1
AddErr(CStr(ErrCount) + ". " + dname + "doesn't appear to be a valid phone no."
If instr(1, fvalue, "-" <> 0 then
ErrCount=Errcount+1
AddErr(CStr(ErrCount) + ". " + dname + "phone number doesn't need to hyphenated"
End If
End IF
End If
End If
End Sub
fvalue=123-444-23
Sub Check_Phone(fvalue,dname)
If len(Trim(fvalue))=0 Then
ErrCount=ErrCount+1
AddErr(Cstr(ErrCount) + ". "+ dname+ " cannot be empty"
else
If IsNumeric(Trim(fvalue))=False Then
ErrCount=ErrCount+1
AddErr(CStr(ErrCount) + ". " + dname + " is not a valid Number"
else
if len(CStr(fvalue)) < 10 then
ErrCount=Errcount+1
AddErr(CStr(ErrCount) + ". " + dname + "doesn't appear to be a valid phone no."
If instr(1, fvalue, "-" <> 0 then
ErrCount=Errcount+1
AddErr(CStr(ErrCount) + ". " + dname + "phone number doesn't need to hyphenated"
End If
End IF
End If
End If
End Sub