Gruppe
Dialog
Problem
Wie kann ich in 3 UserForm-TextBoxes verschiedene, wertmäßige Eingabebegrenzungen festlegen?
ClassModule: frmTxtCntr
Private Sub cmdOK_Click()
Range("D10").Value = CDbl(txtC.Text)
End Sub
Private Sub cmdWeiter_Click()
Unload Me
End Sub
Private Sub txtA_Change()
If txtA.Text = "" Then Exit Sub
If Right(txtA.Text, 1) Like "[!0-9]" Then
txtA.Text = Left(txtA.Text, txtA.TextLength - 1)
End If
If txtA.TextLength = 2 Then
If CInt(txtA.Text) >= 20 And CInt(txtA.Text) <= 50 Then
txtB.SetFocus
Else
Beep
MsgBox "Nur Ganzzahlen zwischen 20 und 50 erlaubt!"
With txtA
.SelStart = 0
.SelLength = .TextLength
End With
End If
End If
End Sub
Private Sub txtB_Change()
If txtB.Text = "" Then Exit Sub
If IsNumeric(txtB.Text) = False Then
txtB.Text = Left(txtB.Text, txtB.TextLength - 1)
End If
If txtB.TextLength = 4 Then
If CDbl(txtB.Text) >= 0.5 And CInt(txtB.Text) <= 30 Then
txtC.Text = (CInt(txtA.Text) + CDbl(txtB.Text)) ^ 5 * 0.25
cmdOK.Visible = True
cmdOK.SetFocus
Else
Beep
MsgBox "Nur Zahlen zwischen 0,5 und 30 erlaubt!"
With txtB
.SelStart = 0
.SelLength = .TextLength
End With
End If
End If
End Sub
StandardModule: basMain
Sub CallForm()
frmTxtCntr.Show
End Sub