Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Arguments in Module Function

Status
Not open for further replies.

Aqif

Programmer
Apr 27, 2002
240
AU
Hi :)

I am trying to pass an argument in my module function. Right now I just want help by giving you all a simple problem.

Lets suppose I have two Forms....FormOne and FormTwo...I want to build a function like this

Function GiveMessage(StrFormNumber as Integer)

Dim StrMsg as String

If StrFormNumber=1 Then
StrMsg="Function is Executed in FormOne"

ElseIf StrFormNumber=2 Then
StrMsg="Function is Executed in FormTwo"

End If

End Function

The way I want use my Function is somewhat like that

On Command Button in FormOne I want to write

GiveMessage(1)

and It should give me message that Function is Executed in FormOne. And If I will pass 2 as function argument then it will give the other message. I am not sure that I am making sense or not but hope someone will understand what I am trying to do.

Cheers!
Aqif
 
Yes Aqif, all that you put makes sense - and all that you put seems fine - so what is the problem ?


Change the Function definition line to
Public Function GiveMessage(StrFormNumber as Integer) As String


After the End If in the Function code add
GiveMessage = strMsg

and on each form call the Function using
Msgbox GiveMessage(1) ' on FormOne
Msgbox GiveMessage(2) ' on FormTwo





'ope-that-'elps.

G LS
 
Thnxxx G LS...it worked like charm n certainly gave me directions to think for more oppertunities n fine tunning my work..

Cheers!
Aqif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top