[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Format and Format$


Il 12/01/25 11:35, Charlie Reinl ha scritto:
Salut,

I have to represent strings like "17,4" or "12" or "0" or "1.001,5"
always with 2 or 4 digits, and there is the problem, the current
language is 'de_DE' but for the decimal separator  I need a dot like in
'en_EN'.
Format prints me "17,4000", but I need "17.4000"
Is there a way to achieve this with Format, or do I need to use
REPLACE?


Hi,

Something like that?

Public Sub Form_Open()

  TextBox1.Text = LangFormat("en_US.UTF-8", "17,4000")
  TextBox2.Text = LangFormat("de_DE.UTF-8", "17,4000")

End

Private Sub LangFormat(sLang As String, s As String) As String

  Dim i As Integer
  i = ReturnInteger(s)

  System.Language = sLang
  s = Format((i / 10000), "#.0000")
  Return s

End

Private Sub ReturnInteger(sText As String) As Integer

  Dim i As Integer

  If sText Then
    sText = Replace(sText, ",", "")
    i = Val(sText)
  Endif
  Return i

End


Follow-Ups:
Re: Format and Format$Karl Reinl <karl.reinl@xxxxxxxxxx>
References:
Format and Format$Charlie Reinl <Karl.Reinl@xxxxxxxxxx>