![]() |
Add() - Printable Version +- Mirage Source (https://mirage-engine.uk/forums) +-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61) +--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18) +---- Forum: Resources (https://mirage-engine.uk/forums/forumdisplay.php?fid=49) +---- Thread: Add() (/showthread.php?tid=369) Pages:
1
2
|
Add() - William - 16-10-2006 Hehe ![]() ![]() Add: Code: Public Function Add(ByVal a As Long, ByVal b As Long) Usage: Code: Dim i As Long "i" would result in 8 ![]() - Spodi - 16-10-2006 Congradulations, you managed to needless slow down and obfuscate the most simple form of math. :lol: :wink: Though learning how to use functions appropriate is a pretty good thing. Just keep in mind that if you have: Code: Public Function MyFunc() You need to define what type of format it is working in as MyFunc will be handled as a variable. In your example, you are making "Add" a variant (default variable format of a variable without a specified format). Code: Public Function MyFunc() As Long Would make Add return a long. Sorry, just wanted to point that out in case you didn't know. :wink: - William - 16-10-2006 I never really added that to my mind.. that part has been so obvious so I kinda never learned it ![]() - William - 16-10-2006 At least Add() looks professional ![]() - Leighland - 16-10-2006 Code: Public Function Add(ByVal a As Long, ByVal b As Long) Awww there ya go Verrigan... lol - Misunderstood - 16-10-2006 Thats too big of an indent ![]() - William - 16-10-2006 and you forgot as long after the function ![]() - Leighland - 17-10-2006 Too long of an indent cuz I did it manually with the spacebar lmao. Code: Public Function Add(ByVal a As Long, ByVal b As Long) As Long - Obsidian - 17-10-2006 i HATE when people don't nest their code... isn't it faster just to do i = 5+3 instead of i = Add(5,3) it's less to type... but congrats for submitting something new :wink: - William - 18-10-2006 Haha..Obsidian, the whole topic was a joke. And you were the only one who didnt get it ![]() - Obsidian - 18-10-2006 oh no i figured it was... :roll: - halla - 18-10-2006 We cant leave subtraction out of the mix. Code: Public Function Subtract(ByVal a As Long, ByVal b As Long) as Long Code: Public Function Multiply(ByVal a As Long, ByVal b As Long) as Long Code: Public Function Divide(ByVal a As Long, ByVal b As Long) as Long There now the basic math functions don't feel left out. - pingu - 18-10-2006 I dare somebody to do square root without the "Sqrt()" functon... - Misunderstood - 18-10-2006 Code: Public Function SquareRoot(ByVal a As Double) as Double - Leighland - 18-10-2006 Rofl, how about percentage? :p - Spodi - 18-10-2006 http://en.wikipedia.org/wiki/Methods_of ... uare_roots - Spodi - 18-10-2006 Code: Public Sub TestOne(ByVal Index As Long) Code: Public Sub TestTwo(ByVal Index As Long) Code: %Faster -98.4| -98.4| -98.4| -98.4| -98.4| -98.4| -98.5| -98.4| -98.4| -98.4 Nope. Not by a long shot. :wink: - halla - 19-10-2006 Leighland Wrote:Rofl, how about percentage? :p What do you mean? - Misunderstood - 19-10-2006 Right, raising to the .5 is generally much slower in most programing languages than the buit in sqrt function. - Spodi - 19-10-2006 Compiled, 5000 loops per each result. :wink: - William - 20-10-2006 Haha.. So my Add command developed itself into a massive math lesson. Well, one thing is good about these. They can easilt be used for sadscript ![]() - William - 20-10-2006 Why, does functions run faster in VB.net? - William - 20-10-2006 I think he means that its not good in VB. But in VB.net.. maybe I missunderstood it.. - Misunderstood - 20-10-2006 William Wrote:I think he means that its not good in VB. But in VB.net.. maybe I missunderstood it.. I think you misunderstood ![]() - William - 20-10-2006 Yeah, guessed so. You ment that it doesn't support Math.Tan etc? |