Question : What does this mean - Passing variables


Hi,

See the line beginning "public function whoa.." below.
I understand the concept of passing variables.   However, what does the "ByRef" and the "As Boolean" bit mean?


Public Function WhoAmI(ByRef who_goes_there As String) As Boolean

Answer : What does this mean - Passing variables


"So, If I want to return a string I should use code like below (??)"
Exactly.

One way (there are many):

Dim sMyStr As String
Dim sPassThis As String

sPassThis = "MX"

sMyStr = WhoAmI (sPassThis) As String   ' you are calling the function here and setting sMyStr to the result - which in this example will be 'Good To Go'

' Now do something with sMyStr ... the result passed back by the Function ... dimmed As String

*********
Modified function:

Public Function WhoAmI(who_goes_there As String) As String
   If who_goes_there = "MX" Then
         WhoAmI = "Good To Go"    
    Else
         WhoAmI = "Bogus"
    End If
End Function
Random Solutions  
 
programming4us programming4us