Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Applying some formatting to a numeric field
Message
De
16/04/2006 09:50:19
 
 
À
15/04/2006 19:56:33
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01113801
Message ID:
01113920
Vues:
17
Glad you got it working ok. =)

~~Bonnie



>>Instead of trying to do macro substitution, all you need to do is figure out the format string. So, you'd have something like this instead:
>>
>>        ' Obtain formatted value
>>        lcFormat = ""
>>        For lnCompteur = 1 To 10
>>            lcFormat = "#" + lcFormat
>>            If lnCompteur Mod 3 = 0 Then
>>                lcFormat = cSeparator + lcFormat
>>            End If
>>        Next
>>
>>        lcValue = tnValue.ToString(lcFormat)
>>
>>        ' If we have decimals
>>        If lnDecimal > 0 Then
>>            lcValue = lcValue + "."
>>            lcValue = lcValue.PadRight(lnDecimal, "0")
>>        End If
>>
>>RETURN lcValue
>>>
>
>Thanks, this is great. This is how the function now looks:
>
>
>    ' Return a transformed value for formatting
>    ' expN1 Value
>    ' expC1 Number of decimal
>    Private Function GetTransform(ByVal tnValue As Integer, Optional ByVal tnDecimal As Integer = 0) As String
>        Dim lnDecimal As Integer
>        Dim lcFormat As String
>        Dim lnCompteur As Integer
>        lnDecimal = 0
>        If tnDecimal > 0 Then
>            lnDecimal = tnDecimal
>        End If
>
>        ' Obtain formatted value
>        lcFormat = ""
>        For lnCompteur = 1 To 10
>            lcFormat = "#" + lcFormat
>            If lnCompteur Mod 3 = 0 Then
>                lcFormat = cSeparator + lcFormat
>            End If
>        Next
>
>        ' If we have decimals
>        If lnDecimal > 0 Then
>            lcFormat = lcFormat + "." + "".PadRight(lnDecimal, "0")
>        End If
>
>        Return tnValue.ToString(lcFormat)
>    End Function
>
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform