Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Use of Functions
#39
@PhilOfPerth the way you are using Subs in place of functions makes clear how functions are so much easier to use and understand. First of all you don't have to rely on special shared variables

Replace Sub One, Two and Three in your example with 2 Functions Twice&(Number&) and StrAdd$(s1$, s2$)

and do it for allot more variables without Shared variables!

For example do this with Subs:
Code: (Select All)
Print "For numbers 1 to 10, show number and Twice it:"
For i = 1 To 10
    Print i; "-"; Twice&(i); "   ";
Next
Print: Print
Print "For letters a - z show the letter and 2 random letters with it"
For i = 1 To 26
    Print Chr$(i + 96); "-"; StrAdd$(Chr$(i + 96), StrAdd$(RndLetter$, RndLetter$)); "   ";
Next
Print

Function Twice& (Number&)
    Twice& = Number& * 2
End Function

Function StrAdd$ (s1$, s2$)
    StrAdd$ = s1$ + s2$
End Function

Function RndLetter$ ()
    RndLetter$ = Chr$(Int(Rnd * 26) + 97)
End Function
b = b + ...
Reply


Messages In This Thread
Use of Functions - by PhilOfPerth - 05-20-2025, 11:21 PM
RE: Use of Functions - by bplus - 05-20-2025, 11:24 PM
RE: Use of Functions - by ahenry3068 - 05-20-2025, 11:34 PM
RE: Use of Functions - by PhilOfPerth - 05-21-2025, 12:25 AM
RE: Use of Functions - by bplus - 05-21-2025, 12:39 AM
RE: Use of Functions - by PhilOfPerth - 05-21-2025, 01:33 AM
RE: Use of Functions - by SMcNeill - 05-21-2025, 02:33 AM
RE: Use of Functions - by PhilOfPerth - 05-21-2025, 04:24 AM
RE: Use of Functions - by ahenry3068 - 05-21-2025, 06:41 AM
RE: Use of Functions - by bplus - 05-21-2025, 09:12 AM
RE: Use of Functions - by SMcNeill - 05-21-2025, 09:45 AM
RE: Use of Functions - by bplus - 05-21-2025, 11:23 AM
RE: Use of Functions - by bplus - 05-21-2025, 11:35 AM
RE: Use of Functions - by Kernelpanic - 05-22-2025, 03:00 PM
RE: Use of Functions - by bplus - 05-21-2025, 11:41 AM
RE: Use of Functions - by SMcNeill - 05-21-2025, 11:45 AM
RE: Use of Functions - by bplus - 05-21-2025, 11:55 AM
RE: Use of Functions - by TempodiBasic - 05-21-2025, 12:06 PM
RE: Use of Functions - by mdijkens - 05-21-2025, 12:11 PM
RE: Use of Functions - by TempodiBasic - 05-21-2025, 08:40 PM
RE: Use of Functions - by Dimster - 05-21-2025, 03:34 PM
RE: Use of Functions - by Kernelpanic - 05-21-2025, 06:01 PM
RE: Use of Functions - by CharlieJV - 05-22-2025, 02:37 AM
RE: Use of Functions - by hsiangch_ong - 05-22-2025, 03:30 PM
RE: Use of Functions - by PhilOfPerth - 05-22-2025, 10:22 PM
RE: Use of Functions - by bplus - 05-22-2025, 11:37 PM
RE: Use of Functions - by madscijr - 05-23-2025, 12:34 AM
RE: Use of Functions - by bplus - 05-23-2025, 10:29 AM
RE: Use of Functions - by bplus - 05-23-2025, 10:49 AM
RE: Use of Functions - by bplus - 05-23-2025, 11:22 AM
RE: Use of Functions - by PhilOfPerth - 05-23-2025, 10:16 PM
RE: Use of Functions - by Pete - 05-23-2025, 10:55 PM
RE: Use of Functions - by madscijr - 05-24-2025, 03:10 AM
RE: Use of Functions - by OldMoses - 05-25-2025, 06:05 PM
RE: Use of Functions - by eoredson - 05-26-2025, 08:59 PM
RE: Use of Functions - by PhilOfPerth - 05-28-2025, 03:32 AM
RE: Use of Functions - by Kernelpanic - 05-26-2025, 11:47 PM
RE: Use of Functions - by Pete - 05-27-2025, 11:25 PM
RE: Use of Functions - by bplus - 05-28-2025, 06:17 AM
RE: Use of Functions - by PhilOfPerth - 05-28-2025, 09:11 AM
RE: Use of Functions - by bplus - 05-28-2025, 09:17 AM
RE: Use of Functions - by PhilOfPerth - 05-28-2025, 09:22 AM
RE: Use of Functions - by SMcNeill - 05-28-2025, 09:53 AM
RE: Use of Functions - by PhilOfPerth - 05-28-2025, 10:59 AM
RE: Use of Functions - by Kernelpanic - 05-28-2025, 05:08 PM
RE: Use of Functions - by TempodiBasic - 05-28-2025, 10:18 PM
RE: Use of Functions - by Pete - 05-29-2025, 12:08 AM
RE: Use of Functions - by Pete - 05-29-2025, 12:22 AM
RE: Use of Functions - by PhilOfPerth - 05-29-2025, 02:02 AM
RE: Use of Functions - by PhilOfPerth - 05-29-2025, 02:42 AM
RE: Use of Functions - by SMcNeill - 05-29-2025, 02:38 AM
RE: Use of Functions - by Pete - 05-29-2025, 06:52 PM
RE: Use of Functions - by Kernelpanic - 05-29-2025, 08:21 PM
RE: Use of Functions - by TempodiBasic - 05-30-2025, 01:49 PM



Users browsing this thread: 2 Guest(s)