Can you check out this function?

Results 1 to 2 of 2

Thread: Can you check out this function?

  1. #1
    Join Date
    Dec 1969

    Default Can you check out this function?

    My function, MaskPhone(), I am having a problem with. Here is the gist of what I want to accomplish: Right now, if you put 7 or 10 numbers in a textbox with this mask, it adds the parentheses and dash where they need to be in order for it to look like a phone number. What it is also supposed to do is to give an error message if there are less than 7 digits or greater than 10. It is not doing this, I am only getting a run-time error (which I don&#039;t want). Can you look at my code and see if it is missing something? Thanks for your time. <BR><BR>&#039;+----------------------------------------------------------------------------<BR>&#039;<BR>&#039; Function: MaskPhone<BR>&#039;<BR>&#039; Description: Takes the innerText or value of the tag (depending on the<BR>&#039; type of tag), and formats it as a 7 or 10 digit phone number.<BR>&#039;<BR>&#039; Arguments: sValue - innerText or value of the tag<BR>&#039;<BR>&#039; Returns: "" (empty string) if sValue is an empty string<BR>&#039; sNewValue - parsed and formatted phone number<BR>&#039;<BR>&#039;-----------------------------------------------------------------------------<BR><BR>function MaskPhone(sValue)<BR><BR> sNewValue = sValue<BR> iLength = 7<BR> stop<BR> &#039; Parse out applicable characters by calling ParseChar()<BR> zChar = Array(" ", "(", ")", "-", ".")<BR> sNewValue = ParseChar(sNewValue, zChar)<BR> <BR> &#039; Determine if this is a 7 or 10 digit phone number<BR> if (len(sNewValue) = 7) then<BR> elseif (len(sNewValue) = 10) then iLength = 10<BR> elseif (len(sNewValue) = 0) then MaskPhone = ""<BR> elseif (len(sNewValue) &#060; 7) then<BR> while (len(sNewValue) &#060; 7) <BR> sNewValue = sNewValue & "0"<BR> ReturnError "Not a valid phone number" &#039;this is another funtion<BR> wend<BR> elseif (len(sNewValue) &#060; 10) then<BR> sNewValue = Mid(sNewValue, 0, 7)<BR> ReturnError "Not a valid phone number"<BR> elseif (len(sNewValue) &#062; 10) then<BR> iLength = 10<BR> if (InStr(sNewValue, 0, 1) = "1" AND len(sNewValue) = 11) then<BR> sNewValue = Mid(sNewValue, 1, 11)<BR> else <BR> sNewValue = Mid(sNewValue, 0, 10)<BR> ReturnError "Not a valid phone number"<BR> end if<BR> end if<BR> &#039; Call FormatPhone() to apply formatting<BR> sNewValue = FormatPhone(sNewValue, iLength)<BR> <BR> MaskPhone = sNewValue<BR>end function

  2. #2
    Join Date
    Dec 1969

    Default RE: Can you check out this function?

    the value u r passing is as integer <BR>convert that into string and then use<BR>& if u want to put zeros<BR>as u can not conconate int and string <BR>i think it will work when u convert that into string first

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts