Domino Code Fragment

Code Name*
Social Security Format
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.140.185.170
Description*
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:
The function follows :
Public Function FormatSocialSecurity(SocSecurityIn As String) As String
Dim SocSec As Variant
Dim nSocSec As Variant
Dim temp As Integer
Dim annuitynumber As Integer
Dim tempstr As String


socsec = SocSecurityIn
nsocsec = socsec
nsocsec = ""


'------------------check if socsec is empty
If Len(socsec) = 0 Then
Exit Function
End If
'------------------Remove formatting if character is neither a number or a letter
For i = 1 To Len(socsec)
If (Mid(socsec,i,1) >= "0" And Mid(socsec,i,1) <= "9") Then
nsocsec = nsocsec & Mid(socsec, i, 1)
End If
Next
'------------------Test for stripped number
'Messagebox nsocsec


'------------------Test for proper Social Security Length
If Len(nsocsec) <> 9 Then
Messagebox "The Social Security Number must be nine digits long. Please re-enter it."
FormatSocSecurity = "Error"
Exit Function
End If


'------------------ Reformat the number in the xxx-xx-xxxx format

socsec = nsocsec
nsocsec = Left(socsec,3) & "-" & Mid(socsec,4,2) & "-" & Mid(socsec,6,4)
Goto done



done:
FormatSocSecurity = nsocsec


End Function

This is the code of the shared field

Use "ScriptName"

Sub Exiting(Source As Field)
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUidocument
Dim doc As NotesDocument


Set uidoc = workspace.CurrentDocument
Set doc = uidoc.document


Dim newSocialSecurity As String
Dim temp As String
*********this is where I get the error
newSocialSecurity = FormatSocSecurity(doc.mfsocialsecurity(0))
*********
If newSocialSecurity = "Error" Then
Call uidoc.gotofield("mfSocialSecurity")
Else
doc.mfSocialSecurity = newSocialSecurity
Call uidoc.reload
Exit Sub
End If
End Sub