Solved

Problem reading data from a text box

Posted on 2000-03-14
3
134 Views
Last Modified: 2010-05-02
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
Comment
Question by:sf129
  • 2
3 Comments
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
Use Val function for textbox.text. For example Val(txtDOB_year).
Cheers
0
 

Author Comment

by:sf129
Comment Utility
Ark, Good job and enjoy my 60 points.
0
 
LVL 27

Accepted Solution

by:
Ark earned 60 total points
Comment Utility
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now