Hi all,
I am trying to figure out (Understand) declorations. The following code sample below will use to illistrate my questions!
In the public function there are items (sLast As string, ....) and i am curious as they appear to just be Dim to me? Why put them in this line?
I guess i am asking why on this example, do you use the (sLast As String, ... ) and then use Dim in the code below it?
Last, debug.print is only in there for the immediate window correct? Other than that it doesnt do anything correct?
Thanks for all the help! I am trying to uderstand these things.
dave
Code:
Option Compare DatabaseOption Explicit
Public Function fcnFullName(sLast As String, sFirst As String, bUseMaiden As Boolean, bUseMaidenLast As Boolean, _
Optional sMaiden As String = "", Optional sMiddle As String = "")
'GoodFullName: fcnFullName([LastName],[FirstName],[UseMaiden],[UseMaidenLast],[MaidenName],[MiddleName])
On Error GoTo Error_Handler
Dim sRslt As String
Dim LN As String
Dim MI As String
If Len(Trim(sMiddle)) > 0 Then MI = Left(sMiddle, 1)
sRslt = Trim(sFirst) & Space(1) & MI & Space(1)
Debug.Print sRslt
LN = sLast
If bUseMaiden = True Then
LN = Trim(sMaiden)
ElseIf bUseMaidenLast = True Then
LN = Trim(sMaiden) & "-" & Trim(sLast)
End If
fcnFullName = sRslt & LN
Error_Handler_Exit:
On Error Resume Next
Exit Function
Error_Handler:
Select Case Err
Case Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure fcnFullName" & "."
End Select
Resume Error_Handler_Exit
End Function