Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Passing multiple variables through functions


I can successfully pass at least one variable to a function but I cannot
pass multiple for the life of me. here is an example

something simple like trying to send a box to hide a group of 2 buttons
as visible

Private Sub cmdHideButtons_Click()
hidegrp(cmdButton1.visible, cmdButton2.visible)

End Sub

Function hidegrp(Value1 as Boolean, Value2 as Boolean)
Value1 = False
Value2 = False

End Function


Now this function Wont work, but i just wanted to illistrate the
principle of passing 2 variables. now if I did it with just one
variable it works fine, other wise it gives me an error *Compile error
: Expected: =*. All i want to know is why it does this and is there a
way around it


--
Xiazer
------------------------------------------------------------------------
Xiazer's Profile: http://www.excelforum.com/member.php...o&userid=31581
View this thread: http://www.excelforum.com/showthread...hreadid=535970

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Passing multiple variables through functions

Xiazer wrote:
I can successfully pass at least one variable to a function but I cannot
pass multiple for the life of me. here is an example

something simple like trying to send a box to hide a group of 2 buttons
as visible

Private Sub cmdHideButtons_Click()
hidegrp(cmdButton1.visible, cmdButton2.visible)

End Sub

Function hidegrp(Value1 as Boolean, Value2 as Boolean)
Value1 = False
Value2 = False

End Function


Now this function Wont work, but i just wanted to illistrate the
principle of passing 2 variables. now if I did it with just one
variable it works fine, other wise it gives me an error *Compile error
: Expected: =*. All i want to know is why it does this and is there a
way around it


You don't need th brackets

Private Sub cmdHideButtons_Click()
hidegrp cmdButton1.visible, cmdButton2.visible
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Passing multiple variables through functions

A couple of things:

Firstly, since you are not returning any value with your hidegrp procedure
it would be better to make it a "Sub" rather than a "Function"

Sub HideGrp(Value1 as Boolean, Value2 as Boolean)

Secondly, the problem is in the calling of the function, rather than the
definition of it and is thanks to a peculiarity in VBA formatting. It does
not particularly like parentheses for some reason. Anyways, either of the
following should work for you: leaving out the parentheses or using the
"Call" keyword. I prefer using Call as I find it less ambiguous.

Private Sub cmdHideButtons_Click()
call hidegrp(cmdButton1.visible, cmdButton2.visible)
End Sub

"Bob Phillips" wrote:

Xiazer wrote:
I can successfully pass at least one variable to a function but I cannot
pass multiple for the life of me. here is an example

something simple like trying to send a box to hide a group of 2 buttons
as visible

Private Sub cmdHideButtons_Click()
hidegrp(cmdButton1.visible, cmdButton2.visible)

End Sub

Function hidegrp(Value1 as Boolean, Value2 as Boolean)
Value1 = False
Value2 = False

End Function


Now this function Wont work, but i just wanted to illistrate the
principle of passing 2 variables. now if I did it with just one
variable it works fine, other wise it gives me an error *Compile error
: Expected: =*. All i want to know is why it does this and is there a
way around it


You don't need th brackets

Private Sub cmdHideButtons_Click()
hidegrp cmdButton1.visible, cmdButton2.visible
End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Functions/Formulas to count multiple variables 2many#s Excel Worksheet Functions 7 June 20th 07 05:20 AM
LOGICAL FUNCTIONS WITH MULTIPLE VARIABLES luiss Excel Worksheet Functions 3 November 18th 05 04:08 PM
Passing Variables Jeff Excel Discussion (Misc queries) 1 November 4th 05 06:46 PM
Passing variables from one sub to another Yasha Avshalumov Excel Programming 4 August 19th 05 04:52 PM
passing variables Squid[_2_] Excel Programming 1 July 27th 04 03:47 AM


All times are GMT +1. The time now is 04:05 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"