Link to home
Start Free TrialLog in
Avatar of CSTANG
CSTANG

asked on

Text Box

Hello,
 
I'm trying to write a code for two text boxes
as below :

txtDat and txtYat

When a user keys in a number in txtDat.
The number is equal to txtYat.Left
(txtYat.Left = txtDat.Text )

If the user Cancel/Delete and blank the
txtDat, then set txtYat.Text = 9120 (But
this must allow the user to re-enter a
new number)

If the user keys in a number beyond the
range of 0 - 11000, then message :
"You are out of Range" and set
txtYat.Text = 9120 (Must allow the
user to re-enter a new number)

Would appreciate if anyone could
lend me a helping hand.


Thank you.

CSTANG

Avatar of AzraSound
AzraSound
Flag of United States of America image

something like this?

Private Sub Form_Load()
    txtDat.CausesValidation = True
End Sub


Private Sub txtDat_Validate(Cancel As Boolean)
    If Val(txtDat) < 0 Or Val(txtDat) > 11000 Then
        MsgBox "You are out of range", vbInformation, "Message"
        txtYat.Text = 9120
        Cancel = True
    ElseIf txtDat = "" Then
        txtYat = 9120
        Cancel = True
    Else
        txtYat.Left = txtDat.Text
    End If
End Sub
ASKER CERTIFIED SOLUTION
Avatar of setiawan
setiawan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial