I don't know how to treat a field name parameter in a function

Post

Posted
Rating:
#1 (In Topic #1151)
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
Hi

I need to pass in name of a field to sqlite3 to process it.

But when I try to treat it I don't know how to do it so that it works for me.

Code (gambas)

  1.  
  2. ' datefield = "[Created  ▽]"  x-----(This field name result is the problem)
  3. ' dateSQLite = "2023-10-01"
  4.  
  5. Public Function sum(resultados As Result, Optional datefield As String = "", Optional dateSQLite As String) As Float
  6.    
  7.    Dim f As Float
  8.    
  9.    While resultados.Available
  10.       If datefield = "" Then
  11.          f += resultados["Amount"]
  12.       Else If resultados[datefield] = dateSQLite Then ' This should work just fine. But, here it breaks because it doesn't recognize the field
  13.          f += resultados["Amount"]        
  14.       Endif
  15.       resultados.MoveNext
  16.    Wend
  17.    
  18.    Return f
  19.    
  20.  

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top

Post

Posted
Rating:
#2
Enthusiast
gambafeliz is in the usergroup ‘Enthusiast’
 The solution is to pass the field without [] and then it works fine.

Example: "Created  ▽"

For your misfortunes I am Spanish and I only know Spanish, please, be patient with me, Thank you. :)
Online now: No Back to the top
1 guest and 0 members have just viewed this.