[Gambas-user] A couple of questions about String.PadRight
Gianluigi
bagonergi at gmail.com
Tue Mar 3 16:02:54 CET 2020
Hi,
I think he wasn't born to do this, but...
Is this correct, being the first on the right and the second on the left of
format?
And instead the strange results of the last two Print (1086.10 and 6.186.1)?
[code]
Public Sub Main()
Dim s As String = "The result of multiplication is "
Dim e As Integer = String.Len(s)
Dim sResult As String = CStr(myResult(12.3, 7))
Dim i As Integer = String.Len(sResult)
' don't takes format into account --->
' The result of multiplication is 6,10
Print String.PadRight(s, (e + i), Format(sResult, ",#.00"))
' OK --->
' The result of multiplication is 86,10
Print String.PadRight(s, (e + i + 1), Format(sResult, ",#.00"))
' takes format into account --->
' The result of multiplication is 86,10
Print String.PadRight(s, (e + i + 1), Format(sResult, "$,#.00"))
' OK --->
' The result of multiplication is € 86,10
Print String.PadRight(s, (e + i + 3), Format(sResult, "$,#.00"))
' --------------------------------------------------------------
' ???
Print String.PadRight(s, (e + i + 3), Format(sResult, ",#.00"))
' ???
Print String.PadRight(s, (e + i + 3), sResult)
End
Private Function myResult(a As Float, b As Float) As Float
Return a * b
End
[/code]
Regards
Gianluigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200303/8a5f194c/attachment.html>
More information about the User
mailing list