Numbers as text
Philipp Knecht
In the PLD of Business One, this was easy to solve.Have you a similar solution in Coresuite ?
Philipp Knecht
We found a function for german numbers.Feel free to adjust it to your language.
In the textbox where the text should appear just bind:
BetragInWorten(System.Math.Floor(DocumentFooter("DocTotal"))) & " komma " & BetragInWorten(CDBL(Right(CINT(DocumentFooter("DocTotal") * 100),2)))Copy the following function into the CommonScript of the template:
Public Function BetragInWorten(ByVal Betrag As Double) _
As String
Dim sBetrag As String
Dim I As Integer
Dim Gruppe As String
Dim tmp1(3) As String
Dim tmp2(3) As String
Dim Grp(4) As String
If Betrag = 0 Then
BetragInWorten = "null"
Else
tmp1(1) = "einemilliarde": tmp2(1) = "milliarden"
tmp1(2) = "einemillion": tmp2(2) = "millionen"
tmp1(3) = "eintausend": tmp2(3) = "tausend"
sBetrag = LTrim(Str(Betrag))
sBetrag = sBetrag.PadLeft(12 ,"0")
For I = 1 To 4
Gruppe = Mid(sBetrag, (I - 1) * 3 + 1, 3)
If Gruppe <> "000" Then
If I <> 4 Then
If Gruppe = "001" Then
Grp(I) = tmp1(I)
Else
Grp(I) = GetGruppe(Gruppe) + tmp2(I)
End If
Else
Grp(I) = GetGruppe(Gruppe)
End If
End If
Next I
BetragInWorten = Grp(1) + Grp(2) + Grp(3) + Grp(4)
End If
End Function
'Die nachfolgende Funktion wird von der Hauptfunktion 'aufgerufen Private Function GetGruppe(ByVal Gruppe As String) As String
'Dreiergruppen in Worten zusammenfassen
Dim Hunderter As String
Dim Zehner As String
Dim Einer As String
'Hunderterstellen
If Val(Mid(Gruppe, 1, 1)) > 0 Then
If Mid(Gruppe, 1, 1) = "1" Then
Hunderter = "einhundert"
Else
Hunderter = Choose(Val(Mid(Gruppe, 1, 1)) + 1, "null", "eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun") + "hundert"
End If
End If
'Zehnerstellen
If Val(Right(Gruppe, 2)) >= 10 And Val(Right(Gruppe, 2)) < 20 Then Einer = Choose(Val(Right(Gruppe, 2)) - 9, "zehn", "elf", "zwölf", "dreizehn", "vierzehn", "fünfzehn", "sechzehn", "siebzehn", "achtzehn", "neunzehn")
Else
If Val(Mid(Gruppe, 2, 1)) > 1 Then
Zehner = Choose(Val(Mid(Gruppe, 2, 1)) - 1, "zwanzig", "dreißig", "vierzig", "fünfzig", "sechzig", "siebzig", "achtzig", "neunzig")
End If
If Val(Mid(Gruppe, 3, 1)) > 0 Then
'Einerstellen
If Zehner = "" Then
Einer = Choose(Val(Mid(Gruppe, 3, 1)) + 1, "null", "eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun")
Else
If Mid(Gruppe, 3, 1) = "1" Then
Einer = "einund"
Else
Einer = Choose(Val(Mid(Gruppe, 3, 1)) + 1, "null", "eins", "zwei", "drei", "vier", "fünf", "sechs", "sieben", "acht", "neun") + "und"
End If
End If
End If
End If
GetGruppe = Hunderter + Einer + Zehner End Function
hth
Olaf Borke
Hi Philipp,for german numbers AND structure very nice! It runs very well, but we need this function for other languages as well.
The problem is not the translation, but the structure (e.g. 75="fünfundsiebzig" in german; "seventyfive" in english).
Are you able, to create a function, which is flexible to the language?
Thanks for answer.
Grüße in die Schweiz
(wir brauchen das nämlich für POLEN)
0
Please sign in to leave a comment.
Comments
0 comments