|
-
Aug 21st, 2008, 04:26 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Function questions (Excel VBA)
Why is that that I can call a function with one input, yet when I have a function with more than 1 something has to be equal to it?
For example:
VB Code:
Sub FunctionTest()
Dim BigNum As Integer
Dim SmallNum As Integer
Dim Output1 As Long
Dim Output2 As Long
'set variable values
BigNum = 15
SmallNum = 5
'call functions
DivBy3 (BigNum)
'DivBy3(BigNum,SmallNum) <--- This yields "Compile Error : Syntax Error"
Test = DivByB(BigNum, SmallNum)
End Sub
Function DivBy3(In_A As Integer)
DivBy3 = In_A / 3
End Function
Function DivByB(In_A As Integer, In_B As Integer)
DivByB = In_A / In_B
End Function
In that example, the function will run for the 1st and third, but not the one commented out. A lot of times, I need the opposite, though.
I set a single variable function equal to something, and I use a dummy variable for the second function, because instead of doing simple math, I'm having the function run other things in the backround.
I just need the function to run and do it's own thing based on the inputs, but I don't need a variable equal to the function.
Am I going about this the wrong way, or is this just how it is?
Thanks for any assistance.
--Fizziii
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|