// Formating a Telephone Number replace Workphone with your element. // this method only formats the number
workphone = "(" + @Left(WorkPhone, 3) + ") " + @Mid(WorkPhone, 4, 3) + "-" + @Right(workPhone, 4)
// This is a step by step method that helps when formating and using with other code
var vwPhone as String var vNewwPhone As String
vwPhone = @Num(WorkPhone) vNewwPhone = "(" + @Left(vwPhone, 3) + ") " + @Mid(vwPhone, 4, 3) + "-" + @Right(vwPhone, 4) WorkPhone = vNewwPhone
// Formats Telephone Number - this version checks for proper amount of digits and // notifies user if there is a problem my element is named HomePhone
var vHPhone as String var vNewHPhone As String var vhphonecount var vhpnentered
Vhpnentered = @num(HomePhone) vhphonecount = @num(@len(vhpnentered))
If vhphonecount = "10"
{ @color(HomePhone,0,7) vHPhone = @Num(HomePhone) vNewHPhone = "(" + @Left(vHPhone, 3) + ") " + @Mid(vHPhone, 4, 3) + "-" + @Right(vHPhone, 4) HomePhone = vNewHPhone } else { @color(HomePhone,7,1) @msgbox("The Telephone Number needs to be Exactly 10 Digits", "The numbers you entered " + @num(Homephone),"is : " + Vhphonecount + " Digits Please check Home Telephone and Re-enter") }
|