Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do we need Functions?
#14
(08-20-2022, 11:59 AM)mnrvovrfc Wrote:
(08-19-2022, 01:36 PM)bartok Wrote: SUB Arrotonda! (num!)
    Arrotonda! = _ROUND(num! * 100) / 100
END SUB

because the "!" is not admited and, without the "!", we will have:

SUB Arrotonda (num!)
    Arrotonda = _ROUND(num! * 100) / 100
END SUB
This is incorrect syntax either way because the name of the "SUB" cannot be used in assignment. Must be a "FUNCTION" instead.

For the first, it was just a demostration about that fact that it didn't work.
For the second, do you like better like this:

SUB Arrotonda (num!)
    num! = _ROUND(num! * 100) / 100
END SUB

I don't have changed "Arrotonda" with "num!"
This doesn't change nothing about what I said. I know that it must be a FUNCTION. In fact I use a FUNCTION and this is the reason why when I made the example as a SUB I forgot the changing. But all the reasoning made, was just to explain in what cases it is better a FUNCTION then a SUB and how avoiding FUNCTIONs in favor of SUBs leads, in these cases, to do things that can be made in a simple way, in a very complicated one. But thank's you for the correction.
Reply


Messages In This Thread
Why do we need Functions? - by PhilOfPerth - 08-19-2022, 01:00 AM
RE: Why do we need Functions? - by OldMoses - 08-19-2022, 01:44 AM
RE: Why do we need Functions? - by bplus - 08-19-2022, 02:05 AM
RE: Why do we need Functions? - by OldMoses - 08-19-2022, 02:12 AM
RE: Why do we need Functions? - by vince - 08-19-2022, 03:40 AM
RE: Why do we need Functions? - by PhilOfPerth - 08-19-2022, 05:40 AM
RE: Why do we need Functions? - by OldMoses - 08-19-2022, 12:58 PM
RE: Why do we need Functions? - by SMcNeill - 08-19-2022, 06:28 AM
RE: Why do we need Functions? - by SMcNeill - 08-19-2022, 06:42 AM
RE: Why do we need Functions? - by PhilOfPerth - 08-19-2022, 08:15 AM
RE: Why do we need Functions? - by bartok - 08-19-2022, 01:36 PM
RE: Why do we need Functions? - by mnrvovrfc - 08-20-2022, 11:59 AM
RE: Why do we need Functions? - by bartok - 08-20-2022, 01:54 PM
RE: Why do we need Functions? - by mnrvovrfc - 08-20-2022, 11:56 AM
RE: Why do we need Functions? - by TempodiBasic - 08-20-2022, 04:52 PM
RE: Why do we need Functions? - by bplus - 08-20-2022, 04:54 PM



Users browsing this thread: 7 Guest(s)