|
-
January 23rd, 2009, 05:38 AM
#1
FormatNumber!! Not working correctly...
Here is another one for the books ...
I use FormatCurrency, and FormatNumber for the GUI data entry modules...
In .Lostfocus I use FormatCurrency, and in .Gotfocus i use FormatNumber..
Code:
Private Sub TxtAmounts_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtMaxBulk.GotFocus, TxtMaxSale.GotFocus _
, TxtMinSale.GotFocus, TxtComm.GotFocus
Dim TmpTxtBox As TextBox = CType(sender, TextBox)
If TmpTxtBox.Text <> "" And Not TmpTxtBox.ReadOnly Then TmpTxtBox.Text = FormatNumber(TmpTxtBox.Text) ' Error here
End Sub
Private Sub TxtCredits_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtMaxBulk.LostFocus, TxtMaxSale.LostFocus _
, TxtMinSale.LostFocus
Dim TmpVal As Double
Dim TmpTxtBox As TextBox = CType(sender, TextBox)
If TmpTxtBox.Text = "" Then
TmpVal = 0
Else
TmpVal = FormatNumber(TmpTxtBox.Text)
End If
TmpTxtBox.Text = FormatCurrency(TmpVal)
End Sub
However I now need to use a Percentage ..
and if i Use FormatPercent .. FormatNumber does not work ..
Code:
Private Sub Txtpercent_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TxtComm.LostFocus
Dim TmpVal As Double
Dim TmpTxtBox As TextBox = CType(sender, TextBox)
If TmpTxtBox.Text = "" Then
TmpVal = 0
Else
TmpVal = FormatNumber(TmpTxtBox.Text)
End If
TmpTxtBox.Text = FormatPercent(TmpVal , 0, TriState.True, TriState.False, TriState.False)
End Sub
I simply get
Conversion from string "0%" to type 'Double' is not valid.
I thought that FormatNumber is supposed to return the numeric in any number format ... Why cant it handle percents..    
Gremmy..
Last edited by GremlinSA; January 23rd, 2009 at 06:51 AM.
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|