Re: add +1 value to textbox
Text1.Text = Format(Val(Text1.Text + 1), "0000")
Re: add +1 value to textbox
Quote:
Originally Posted by
masoudk1990
Text1.Text = Format(Val(Text1.Text + 1), "0000")
thanx work like charm
Re: add +1 value to textbox
how i set textbox limit to 9999
Re: add +1 value to textbox
Quote:
Originally Posted by
vbnoob00
how i set textbox limit to 9999
Code:
Private Sub Form_Load()
Text1.MaxLength = 4
End Sub
Private Sub Command1_Click()
If (Val(Text1.Text) < 1000) Then
Text1.Text = Format(Val(Text1.Text + 1), "0000")
End If
End Sub
If you wish user only be able to write numbers in textbox write this code in keypress event of textbox
Code:
If (KeyAscii < 48 And KeyAscii <> 8) Or (KeyAscii > 57) Then 'numbers and backspace only :)
KeyAscii = 0
End If
Re: add +1 value to textbox
Quote:
Originally Posted by
masoudk1990
Private Sub Form_Load()
Text1.MaxLength = 4
End Sub
if it go over i wana display msg box error
Re: add +1 value to textbox
Quote:
Originally Posted by
vbnoob00
if it go over i wana display msg box error
Code:
If Val(Text1.Text < 1000) Then
Text1.Text = Format(Val(Text1.Text + 1), "0000")
Else
MsgBox "Overflow!", vbCritical, "Error!"
End If
Re: add +1 value to textbox
genius thanxxxx
Quote:
Originally Posted by
masoudk1990
Code:
If Val(Text1.Text < 1000) Then
Text1.Text = Format(Val(Text1.Text + 1), "0000")
Else
MsgBox "Overflow!", vbCritical, "Error!"
End If
Re: add +1 value to textbox
Quote:
Originally Posted by
vbnoob00
if it go over i wana display msg box error
If you set the maxlength to 4, one CANNOT type in anything larger than 4 characters...so no msgbox would be needed anyway.....
Re: add +1 value to textbox
Quote:
Originally Posted by
vbnoob00
genius thanxxxx
i keep getting that msgbox even on 0001 :(
Re: add +1 value to textbox
Quote:
Originally Posted by
vbnoob00
i keep getting that msgbox even on 0001 :(
Sorry :)
Code:
If (Val(Text1.Text) < 9999) Then
Text1.Text = Format(Val(Text1.Text + 1), "0000")
Else
MsgBox "Overflow!", vbCritical, "Error!"
End If