Textbox Condition

I have Textbox with maxlenght of 4 characters;

If Textbox1.text = (is not a number) then
   Textbox1.text = DateTime.Now.ToString ("yyyy")
End If

Thanks for the help
Rowel VirgoVisual Studio .NETAsked:
Who is Participating?
Éric MoreauConnect With a Mentor Senior .Net ConsultantCommented:
Shaun VermaakConnect With a Mentor Technical Specialist/DeveloperCommented:
Dim number As Integer

Dim result As Boolean = Int32.TryParse(Textbox1.text, number)
If Not result Then
    Textbox1.text = DateTime.Now.ToString("yyyy")
End If

Open in new window

Éric MoreauSenior .Net ConsultantCommented:
asker never came back!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.