> ' Format a value > ' expC1 Separator > ' expN2 Number of decimals > Public Function GetFormat(ByVal tcSeparator As String, ByVal tnDecimal As Integer) As String > Dim lcFormat As String = "" > Dim lnCounter As Integer = 0 > > ' Obtain formatted value > For lnCounter = 1 To 9 > lcFormat = "#" + lcFormat > > If lnCounter Mod 3 = 0 Then > lcFormat = tcSeparator + lcFormat > End If > > Next > > lcFormat = lcFormat + "0" > > ' If we have decimals > If tnDecimal > 0 Then > lcFormat = lcFormat + "." + "".PadRight(tnDecimal, "0") > End If > > Return lcFormat > End Function > > ' Format a value for a dollar > ' expN1 Value > ' expC1 Separator > Public Function GetFormatValueDollar(ByVal tnValue As Double, ByVal tcSeparator As String) As String > Dim lcFormat As String = "" > Dim lcValue As String = "" > Dim llDollarSignToTheRight As Boolean = True > > lcFormat = GetFormat(tcSeparator, 2) > lcValue = Format(tnValue, lcFormat) + "$" > > ' If we format the dollar sign as per the language > If oApp.lFormatDollarAsPerTheLanguage Then > > ' Based on the language > Select Case nLanguage > > ' English > Case 1 > lcValue = "$" + Format(tnValue, lcFormat) > > ' French > Case 2 > lcValue = Format(tnValue, lcFormat) + "$" > > ' Spanish > Case 3 > lcValue = Format(tnValue, lcFormat) + "$" > > ' Portuguese > Case 4 > lcValue = Format(tnValue, lcFormat) + "$" > > End Select > > End If > > Return lcValue > End Function >I guess that boils down to this line:
lcValue = Format(tnValue, lcFormat) + "$"
which is using the legacy Microsoft.VisualBasic.Strings stuff. I don't really remember how that worked but I think it translates based on the Windows locale rather then the .NET current culture. Why not just use the .NET .ToString() methods e.g.:Public Function GetFormatValueDollar(ByVal tnValue As Double, ByVal nLanguage As Integer) As String Dim info As CultureInfo Select Case nLanguage Case 1 info = New CultureInfo("en-US") Case Else info = New CultureInfo("fr-CA") ' If you want different separators: info.NumberFormat.CurrencyDecimalSeparator = "." info.NumberFormat.CurrencyGroupSeparator = "," End Select Return tnValue.ToString("c", info) End Function