Function return values as string

Calc(a as double, ByRef x as double, ByRef y as double,ByRef z as double) as double

Is it possible to convert this above function for string returning values like:
Calc( a as double) as string
x=a *10
y=a *100
z= a * 1000
return x + “|” + y + “|” + z

Yes. Did you try it?

Naturally, you would have to convert the numbers to strings via Str or Format.

why change it? Byref is okay for that.

Because I am Using this Function:

  Public Function LBR_For(Object_Name, At_JDE)
'             LBR_For_Terre_or_Soleil()
'             LBR_For_Mercure()
'             LBR_For_Venus()
'             LBR_For_Mars()
'             LBR_For_Jupiter()
'             LBR_For_Saturne()
'             LBR_For_Uranus()
'             LBR_For_Neptune()

  Dim LBR    As String
      LBR = "ERROR"

  Dim Object As String
  Object = UCase(Trim(Object_Name))
  
  If Object = "SOLEIL" Then LBR = LBR_For_Terre_or_Soleil(At_JDE, "S")
  If Object = "EARTH" Then LBR = LBR_For_Terre_or_Soleil(At_JDE, "T")
  If Object = "LUNE" Then LBR = LBR_For_Lune(At_JDE)
  If Object = "MERCURE" Then LBR = LBR_For_Mercure(At_JDE)
  If Object = "VENUS" Then LBR = LBR_For_Venus(At_JDE)
  If Object = "MARS" Then LBR = LBR_For_Mars(At_JDE)
  If Object = "JUPITER" Then LBR = LBR_For_Jupiter(At_JDE)
  If Object = "SATURNE" Then LBR = LBR_For_Saturne(At_JDE)
  If Object = "URANUS" Then LBR = LBR_For_Uranus(At_JDE)
  If Object = "NEPTUNE" Then LBR = LBR_For_Neptune(At_JDE)
 
  If LBR = "ERROR" Then
     LBR_For = LBR & ": """ & Object & """ = Nom inappropri !"
     Beep
     Exit Function
  End If

  LBR_For = LBR

  End Function

Also, all planets returns spherical Coordinates L,B,R as string in the format : L + “|” + B + “|” + R

// // For 'Calc( a as double) as string', the following should work. // Return Trim( Str( L)) + "|" + Trim( Str( B)) + "|" + Trim( Str( R))

Al those If’s on the same field always gives me the creeps.
Why not using the well-organized and more efficient Select Case?

Xojo Documentation - Select Case

...

Select Case Object
Case "SOLEIL"
  LBR = LBR_For_Terre_or_Soleil(At_JDE, "S")
Case "EARTH"
  LBR = LBR_For_Terre_or_Soleil(At_JDE, "T")
Case "LUNE"
  LBR = LBR_For_Lune(At_JDE)
Case "MERCURE"
  LBR = LBR_For_Mercure(At_JDE)
Case "VENUS"
  LBR = LBR_For_Venus(At_JDE)
Case "MARS"
  LBR = LBR_For_Mars(At_JDE)
Case "JUPITER"
  LBR = LBR_For_Jupiter(At_JDE)
Case "SATURNE"
  LBR = LBR_For_Saturne(At_JDE)
Case "URANUS"
  LBR = LBR_For_Uranus(At_JDE)
Case "NEPTUNE"
  LBR = LBR_For_Neptune(At_JDE)
Else
  LBR = "ERROR"
End Select

...

[quote=101599:@Djamel AIT AMRANE]Calc(a as double, ByRef x as double, ByRef y as double,ByRef z as double) as double

Is it possible to convert this above function for string returning values like:
Calc( a as double) as string
x=a *10
y=a *100
z= a * 1000
return x + “|” + y + “|” + z[/quote]

You can’t simply concatenate numbers and strings like that. You have to convert the numbers to strings with str, e.g., str(x) + “|” + str(y) etc

[quote]
Paul Sondervan
2 hours ago Beta Testers, Xojo Pro Europe (Netherlands, Den Haag)

Al those If’s on the same field always gives me the creeps.
Why not using the well-organized and more efficient Select Case?[/quote]

Yes, Select case i good alternative to If Then sometimes, thank you.

[quote]
Syed Hassan
4 hours ago Beta Testers, Xojo Pro

//
// For ‘Calc( a as double) as string’, the following should work.
//
Return Trim( Str( L)) + “|” + Trim( Str( B)) + “|” + Trim( Str( R))[/quote]

i get Message Syntax Error, my function in written like this under VB6:
LBR_For(Object_Name , At_JDE as double) as string
Function LBR_For_Venus(At_JDE as double)

’ Return LBR values within a delimited string.
LBR_For_Venus = L & “|” & B & “|” & R
End function

Under Xojo it looks like this:
LBR_For_Venus(At_JDE as double) as string


return L + “|” + B + “|” + R

[quote=101778:@Djamel AIT AMRANE]i get Message Syntax Error,



Under Xojo it looks like this:
LBR_For_Venus(At_JDE as double) as string


return L + “|” + B + “|” + R[/quote]
The message ‘Syntax Error’ requires qualification. What is the line of code showing this error please?

// // Function ReturnString() As String // // This compiles and executes without any error. // Dim L, B, R As Double L = 1.23 B = 2.34 R = 3.45 Dim strReturn As String strReturn = Trim( Str( L)) + "|" + Trim( Str( B)) + "|" + Trim( Str( R)) Return strReturn

[quote=101778:@Djamel AIT AMRANE]i get Message Syntax Error
return L + “|” + B + “|” + R[/quote]

As 2 different people have explained to you already, you can’t concatenate numbers and strings that way. You have to use the str function.

Yes, it’s ok now,
Dim strReturn As String
strReturn = Trim( Str( L)) + “|” + Trim( Str( B)) + “|” + Trim( Str( R)), thank you for all.