Passing parameters?

F

flying_pig

Although I have a basic understanding of inter-marco parameter passing I seem
to be doing something wrong (see code extract below). It will work sending
strings in quotes but does not accept String variables.

The called macro:

Sub Recieve(TextA,TextB,TextC as String,ValueA,ValueB,ValueC as integer)

MSGBOX(TextA) 'test to show they arrive (others not shown here)
..
..
..
..


End Sub

The calling Macro:

Sub SendTextandValues()

Dim MyTextA, MyTextB, MyTextC as String
Dim MyValue1, MyValue2, MyValue3 as Integer

MyTextA="Text_A"
MyTextB="Text_B"
MyTextC="Text_C"
MyValue1= 1
MyValue2= 2
MyValue3= 3


'using call
Call Recieve(TextA,TextB,TextC,ValueA,ValueB,ValueC)
..
..
'not using call doesn't work either as here:
' Recieve TextA,TextB,TextC,ValueA,ValueB,ValueC
..
..
..

End Sub

Any suggestions please?
 
F

flying_pig

flying_pig said:
Although I have a basic understanding of inter-marco parameter passing I seem
to be doing something wrong (see code extract below). It will work sending
strings in quotes but does not accept String variables.

The called macro:

Sub Recieve(TextA,TextB,TextC as String,ValueA,ValueB,ValueC as integer)

MSGBOX(TextA) 'test to show they arrive (others not shown here)
.
.
.
.


End Sub

The calling Macro:

Sub SendTextandValues()

Dim MyTextA, MyTextB, MyTextC as String
Dim MyValue1, MyValue2, MyValue3 as Integer

MyTextA="Text_A"
MyTextB="Text_B"
MyTextC="Text_C"
MyValue1= 1
MyValue2= 2
MyValue3= 3


'using call
Call Recieve(MyTextA,MyTextB,MyTextC,MyValueA,MyValueB,MyValueC)
.
.
'not using call doesn't work either as here:
' Recieve TextA,TextB,TextC,ValueA,ValueB,ValueC
.
.
.

End Sub

Any suggestions please?
 
F

flying_pig

Problem solved: I now realise the variable type can only be declared once.

I did want a specific order such as Text number Text Number but it seems
that the declaration must be thus:

Sub Test(Text1,Text2 As String, Number1, Number2 as Integer)

This works ok now.
 
J

John Wilson

See if this works better then:

Sub SendTextandValues()

Dim MyTextA As String, MyTextB As String, MyTextC As String
Dim MyValue1 As Integer, MyValue2 As Integer, MyValue3 As Integer

MyTextA = "Text_A"
MyTextB = "Text_B"
MyTextC = "Text_C"
MyValue1 = 1
MyValue2 = 2
MyValue3 = 3
'using call
Call Recieve(MyTextA, MyTextB, MyTextC, MyValue1, MyValue2, MyValue3)
End Sub

Sub Recieve(TextA, TextB, TextC, ValueA, ValueB, ValueC)
MsgBox (TextA) 'test to show they arrive (others not shown here)
End Sub

NB Your method of Declaring the string and Integer variables will declare
the first two in each case as Variants not strings or Integers - it will work
but it's not good!
--
Amazing PPT Hints, Tips and Tutorials

http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html
_______________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top