Click to See Complete Forum and Search --> : Ok. Some questions about Public Functions.
Apollo
Nov 4th, 1999, 05:02 AM
In creating a function, what must I do?
Do I need to write
Public Function MYFACTORIAL(number as integer, otherone as integer, lastone as integer)
number = otherone * lastone
end function
Or what? Someone show me the correct syntax for a public function. Thank you, goodbye.
------------------
"I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"
QWERTY
Nov 4th, 1999, 05:11 AM
Hope this will work:
Public Function Factorial (anotherone as integer, lastone as integer)
Factorial=AnotherOne * LastOne
End Function
To call this function and calculate value for Number do:
Number=Factorial (AnotherOne, LastOne)
------------------
Visual Basic Programmer
-----------------
PolComSoft
You will hear a lot about it.
Apollo
Nov 4th, 1999, 05:22 AM
Well, would the same go for a for-next statement?
Public Function MYFACTORIAL(numberin as Integer, newnumber as integer,counter as integer)
MYFACTORIAL = For counter = 1 to numberin
newnumber = newnumber * counter
next
end function
Would it?
------------------
"I'm carrying a Geometry book, but I'm not in Geometry...it's crazy...crazy man!"
Serge
Nov 4th, 1999, 05:33 AM
Not exactly:
Public Function MyFactorial(NumberIn As Integer)
Dim i As Integer
For i = 1 To NumberIn
MyFactorial = MyFactorial + NumberIn
Next
End Function
Example: MsgBox MyFactorial 10
The result would 55.
Regards,
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819
[This message has been edited by Serge (edited 11-04-1999).]
QWERTY
Nov 4th, 1999, 05:36 AM
Public Function Factorial(numberin As Integer)
dim Counter as Integer
Factorial = 1
For counter = 1 To numberin
Factorial = Factorial * counter
Next counter
End Function
To call this function
Number=factorial(NumberIn)
Hope this what You are looking for
------------------
Visual Basic Programmer
-----------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 11-04-1999).]
QWERTY
Nov 4th, 1999, 05:38 AM
Serge's method will only work for addition and substraction because if you use multiplication or division or something like that you will always have Factorial value of 0. On the other hand my method won't work for addition and substraction
------------------
Visual Basic Programmer
-----------------
PolComSoft
You will hear a lot about it.
[This message has been edited by QWERTY (edited 11-04-1999).]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.