x
Solved

# Problem reading data from a text box

Posted on 2000-03-14
Medium Priority
150 Views
i am trying to read two numbers out of a textbox(date of birth) and compare those numbers with two other numbers(today's actual date) but for some reason it is only picking up the first digit.  It is not recognizing the second digit.  I have cut and pasted a copy of code.  Can you please help me correct my problem?

Option Explicit
Private Sub cmdCalculateAge_Click()
If txtDOB_month.Text = Month(Date) Then
If txtDOB_day.Text <= Day(Date) Then
txtCalculatedAge.Text = Year(Date) - txtDOB_year
Else
txtCalculatedAge.Text = (Year(Date) - txtDOB_year) - 1
End If
Else
If txtDOB_month.Text < Month(Date) Then
txtCalculatedAge.Text = Year(Date) - txtDOB_year
Else
txtCalculatedAge.Text = (Year(Date) - txtDOB_year) - 1
End If
End If
End Sub
0
Question by:sf129
• 2

LVL 28

Expert Comment

ID: 2618362
Hi
Use Val function for textbox.text. For example Val(txtDOB_year).
Cheers
0

Author Comment

ID: 2618381
Ark, Good job and enjoy my 60 points.
0

LVL 28

Accepted Solution

Ark earned 240 total points
ID: 2618383
Hi
This code works
Option Explicit
Private Sub Command1_Click()
If Val(Text2) = Month(Date) Then
If Val(Text3) <= Day(Date) Then
Text4 = Year(Date) - Val(Text1)
Else
Text4 = (Year(Date) - Val(Text1)) - 1
End If
Else
If Val(Text2) < Month(Date) Then
Text4 = Year(Date) - Val(Text1)
Else
Text4 = (Year(Date) - Val(Text1)) - 1
End If
End If
End Sub
Cheers
0

## Featured Post

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.