Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem reading data from a text box

Posted on 2000-03-14
3
Medium Priority
?
145 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 28

Expert Comment

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

Author Comment

by:sf129
ID: 2618381
Ark, Good job and enjoy my 60 points.
0
 
LVL 28

Accepted Solution

by:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses

610 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