hmk
Active Member
- Joined
- Jun 8, 2004
- Messages
- 423
Hi there
When I put this formating to the value of TextBoxs,
However, when i cancel the formating then the equation gives correct result but with no comma nor period.....which are realy needed
Then the result of this line is always 1 or not correct
How can get the correct result out of equation ?
The whole code:
When I put this formating to the value of TextBoxs,
Code:
Gtot.Value = Format(Gtot.Value, "#,##0.000")
tot.Value = Format(tot.Value, "#,##0.000")
bal.Value = Format(bal.Value, "#,##0.000")
Then the result of this line is always 1 or not correct
Code:
bal.Value = val(Gtot.Value) - val(tot.Value)
How can get the correct result out of equation ?
The whole code:
Code:
Private Sub cmdAdd_Click()
MyCalc
tot.Value = ""
End Sub
Private Sub bal_Change()
bal.Value = Format(bal.Value, "#,##0")
End Sub
Private Sub tot_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'tot.Value = Format(tot.Value, "#,##0.000")
With Me.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Sorry, only numbers allowed"
.Value = vbNullString
ElseIf Left(.Value, 1) = "-" And IsNumeric(Left(.Value, 2)) Then
Exit Sub
End If
End With
End Sub
Private Sub Gtot_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'Gtot.Value = Format(Gtot.Value, "#,##0.000")
With Me.ActiveControl
If Not IsNumeric(.Value) And .Value <> vbNullString Then
MsgBox "Sorry, only numbers allowed"
.Value = vbNullString
ElseIf Left(.Value, 1) = "-" And IsNumeric(Left(.Value, 2)) Then
Exit Sub
End If
End With
End Sub
Sub MyCalc()
If tot.Value = "" Then Exit Sub
If tot.Value <> 0 Then
bal.Value = val(Gtot.Value) - val(tot.Value)
Exit Sub
End If
End Sub