How to convert Variables to String with CStr() and Str()      zurueck

You can use Str() or CStr() to convert a variable to String.

Str() uses your language enviroment, which is defined by LANG (shell: echo $LANG)
CStr() does not.

My language enviroment is german:

jochen@archie:~$ echo $LANG
de_DE@euro

In the screenshot you see the result of Str(4.6), which is 4,6.
The comma is set, because that's the way a decimal number is written in germany.

The Program

The Code:

STATIC PUBLIC SUB Main()
  hForm AS Fmain
  hForm = NEW Fmain
  hForm.show
END

PUBLIC SUB Button1_Click()
   Label2.Text = Str(4.6)
   Label4.Text = CStr(4.6)
   Label6.Text = Str(23456)
   Label8.Text = CStr(23456)
   Label10.Text = Str(TRUE)
   Label12.Text = CStr(TRUE)
END

hi gambasians,
 
 in the enceclopedeia stands:
 CStr:
 Converts an expression into a string.  Be careful, the current 
 localization is NOT used by this function.
  what is the current localization?
 what does that mean?
  thanks for all hints
  beste gruesse
 jochen
 From: Fabien BODARD <abidoo@wa...> 
  Re: CStr - localization   
2003-02-09 02:13 
If you use Japanese or Greek you may have some problem...do you understand? it's for the characters style.
Fabien
For example, in American :
PRINT CStr(1.234)
 1.234
 PRINT Str$(1.234)
  1.234
 And in French :
 PRINT CStr(1.234)
 1.234
 PRINT Str$(1.234)
  1,234
 Str$ uses the current application language stored in the LANG and LC_*  environment variables.
  CStr does not !
  -- 
 Benoît Minisini