Creating Public and Private Functions in VB6
From Free Knowledge Base- The DUCK Project: information for everyone
Function Example
Private Function fnFormatPhoneNum(strIn As String) As String Dim strLen As Integer strIn = Trim(strIn): strLen = Len(strIn) Select Case strLen Case 10 fnFormatPhoneNum = "(" & Right(strIn, 3) & ") " & Mid(strIn, 3, 3) & "-" & Left(strIn, 4) Case 7 fnFormatPhoneNum = Right(strIn, 3) & "-" & Left(strIn, 4) Case Else fnFormatPhoneNum = strIn End Select End Function
Here's how to call the function above from the program code:
strVariableName = fnFormatPhoneNum("" & arCompanies(cnt, 4))