Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FUNCTION Event(x AS DOUBLE) AS DOUBLE
#1
Before creating a function I normally would Dimension x as Double BEFORE I actually call the function. For example

Dim x as Double
...code..
...code..

x = Event
...
Function Event(x)
...code...
End Function

But, dimensioning on an "as needed basis" or "on the run" what is the correct syntax

Function Event (x as Double) as Double or Function Event(x) as Double or Function Event (x as Double)??

It's hard to give up on the old ways, if they worked, to learn a new more efficient way. (by efficient I mean to reduce all those Dim Shared variables I have at the beginning of my code to only creating them when they are actually called for service.
Reply
#2
(01-26-2024, 04:17 PM)Dimster Wrote: . . .
Function Event (x as Double) as Double or Function Event(x) as Double or Function Event (x as Double)??

It's hard to give up on the old ways, if they worked, to learn a new more efficient way. (by efficient I mean to reduce all those Dim Shared variables I have at the beginning of my code to only creating them when they are actually called for service.
I don't really understand what you actually want. . .  Huh

Code: (Select All)

'Declaration
Declare Function Endpreis(kaufpreis, mehrwertSteuer As Double) As Double

. . . Code

'Definition
Function Endpreis (kaufpreis, mehrwertSteuer As Double)

  Dim As Double gesamtpreis

  gesamtpreis = kaufpreis + ((kaufpreis * mehrwertSteuer) / 100)
  Endpreis = gesamtpreis
End Function
Reply
#3
Are you looking for:

FUNCTION Event# (x AS DOUBLE)

The # after the name Event denotes it as returning a double value back to us.  Wink
Reply
#4
Code: (Select All)
PRINT Event

FUNCTION Event# (x AS DOUBLE)

    'code here
    Event = 1000

END FUNCTION
.
You can't declare a function AS DOUBLE, you must instead use the type identifier as shown above.

Update: Steve beat me to it my mere seconds Smile
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply
#5
That where I've  missed the boat - the correct syntax is 
FUNCTION Event#(x as double)
Thank you
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Star Suggestion for new REPLACE$() function zaadstra 3 238 01-26-2026, 05:11 PM
Last Post: grymmjack
  Is there a menu function? Mad Axeman 17 1,019 12-17-2025, 04:43 AM
Last Post: SMcNeill
  SCREEN Function CletusSnow 8 803 11-16-2025, 05:09 PM
Last Post: TempodiBasic
  An Odd Event with Printstring & Uprintstring Dimster 3 515 09-21-2025, 03:41 PM
Last Post: Dimster
  Using the Screen function PhilOfPerth 19 3,046 04-16-2024, 05:23 PM
Last Post: bobalooie

Forum Jump:


Users browsing this thread: 1 Guest(s)