The Matrix
February 17th, 2000, 09:39 AM
when do i use the call statement, like:
call whatever
when i make a function i dont have to use "call"
call whatever
when i make a function i dont have to use "call"
|
Click to See Complete Forum and Search --> : Calling The Matrix February 17th, 2000, 09:39 AM when do i use the call statement, like: call whatever when i make a function i dont have to use "call" Nick A. February 17th, 2000, 09:52 AM I don't think you have to use it. If you see the help on "Call", it clearly says that it is an optional keyword. Personaly, i don't use it at all. Johnny101 February 17th, 2000, 09:56 AM I don't think there is any difference between calling a sub, or function with or without the "Call" in front. For a sub routine, it's really a matter of personal choice - If you place "Call" in front, it lets other programmers know that that really is a subroutine being activated at that point and not some built in routine. As for functions that return values and take parameters, - pretty much the same thing - personal choice. There is one little difference between the two syntaxes though: Function MyFun(Param1 as string, Param2 as string) as Boolean 'blah blah blah End Funtion 'would be called like this: Call MyFun(FirstParam, SecondParam) 'or.. MyFun FirstParam, SecondParam In both of the above cases, you dont care about the returning value of the function. If you need to know what the function is returning, then set a variable equal to the function call: Dim bReturnValue as Boolean bReturnValue = MyFun(FirstParam,SecondParam) The main difference is in the parenthesis. Using "Call" they are there, not using it, they aren't. Hope this helps, John John Pirkey MCSD www.ShallowWaterSystems.com Ravi Kiran February 17th, 2000, 10:25 PM Though i cannot say when to use call, all that i can say from my vb programming is there is a subtle difference between SomeFunc someinput and Call SomeFunc(someinput) Specially when you write functions/subs which take object or control pointers, because without the explicit Call and ( ), VB sometimes replaces it with default value or property, and sometimes (in not so well written codes) can give problems/unexpected behaviours. RK codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |