GremlinSA
January 23rd, 2009, 04:38 AM
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..
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 .. 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.. :confused::(:cry::mad:
Gremmy..
I use FormatCurrency, and FormatNumber for the GUI data entry modules...
In .Lostfocus I use FormatCurrency, and in .Gotfocus i use FormatNumber..
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 .. 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.. :confused::(:cry::mad:
Gremmy..