PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Passing Parameters  (Read 407 times)

Klaas Holland

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 90
  • FF3 User
Passing Parameters
« on: June 19, 2017, 11:43:56 AM »

In CDbl and CLng you can pass both a String expression or a Numeric expression.

Is it possible to create a Function with these possibilities?

If so, how do you do it?
Logged

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: Passing Parameters
« Reply #1 on: June 19, 2017, 02:31:23 PM »

Yes.

Code: [Select]
FUNCTION Foo OVERLOAD (BYVAL x AS DOUBLE) AS LONG
FUNCTION Foo OVERLOAD (BYREF x AS STRING) AS LONG

Klaas Holland

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 90
  • FF3 User
Re: Passing Parameters
« Reply #2 on: June 19, 2017, 06:21:04 PM »

Sorry, but how do I implement this here?

Code: [Select]
Function EFormat (ByVal nValue as Long) as String

    Dim as String v = Format (nValue/100, "#.00")
   
    Function = v
End Function
Logged

Josť Roca

  • FireFly3 Registered User
  • Master FireFly Member
  • *
  • Posts: 2785
    • Josť Roca Software
Re: Passing Parameters
« Reply #3 on: June 19, 2017, 06:34:19 PM »

Code: [Select]
Function EFormat Overload (ByVal nValue as Long) as String
    Dim as String v = Format (nValue/100, "#.00")
    Function = v
End Function

Function EFormat Overload (ByRef strValue as String) as String
    Dim as String v = Format (Val(strValue)/100, "#.00")
    Function = v
End Function

Usage:

print EFormat(1234)
print EFormat("1234")
« Last Edit: June 19, 2017, 06:37:04 PM by Josť Roca »
Logged

Klaas Holland

  • FireFly3 Registered User
  • Junior FireFly Member
  • *
  • Posts: 90
  • FF3 User
Re: Passing Parameters
« Reply #4 on: June 20, 2017, 07:14:54 AM »

Thanks Jose,
You are a genius.
Logged