Tridiro
Board Regular
- Joined
- Apr 26, 2007
- Messages
- 97
Hello Everyone,
I have a simple problem that is kicking my Butt, I have a userform which contains a textbox where the DOB is entered. I have a button that contain code that calculates the age and populates another textbox. I know when a number is entered into a textbox VBA handles it as text and not a number. I attempted to fix this problem with the val(string) command. Here is my code
I have a simple problem that is kicking my Butt, I have a userform which contains a textbox where the DOB is entered. I have a button that contain code that calculates the age and populates another textbox. I know when a number is entered into a textbox VBA handles it as text and not a number. I attempted to fix this problem with the val(string) command. Here is my code
Code:
Private Sub CommandButton6_Click()
Dim MyDOB As Date
Dim MyNow As Date
MyDOB = Val(UFNewClient.TextBoxDOB.Value)
MyNow = Int(Now)
UFNewClient.TextBoxAGE.Value = DateDiff(y, MyDOB, MyNow)
End Sub
[Code]/
Last edited: