Hi Fabian,
Following procedures check if the entered value is an integer and if so formatt it to currency.
The currencyformat is subject to the regional settings in Windows so it will apply Your local regional settings:
Private Sub TextBox3_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Cancel = CheckValue(TextBox3)
If Cancel = False Then
With TextBox3
.Text = FormatCurrency((.Text) * 1, NumDigitsAfterDecimal:=0)
End With
End If
End Sub
Private Function CheckValue(TxtBox As MSForms.TextBox) As Boolean
Dim stValue As String
stValue = TxtBox.Text
If IsNumeric(stValue) Then
If stValue < 0 Then
MsgBox "The input must be greater then 0.", vbExclamation
TxtBox.Text = ""
CheckValue = True
ElseIf stValue - Int(stValue) = 0 Then
CheckValue = False
Else
MsgBox "The number must be an integer.", vbExclamation
TxtBox.Text = ""
CheckValue = True
End If
Else
MsgBox "The input must a value and an integer.", vbExclamation
TxtBox.Text = ""
CheckValue = True
End If
End Function
Kind regards,
Dennis


LinkBack URL
About LinkBacks



Reply With Quote

Bookmarks