Solved

Problem reading data from a text box

Posted on 2000-03-14
3
139 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
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 27

Accepted Solution

by:
Ark earned 60 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Basic Excel Formatting error 4 105
Adding to a VBA? 6 70
how to Classify of email (pdf attachments) 7 36
VBA - If Bookmark = "XXBOOKMARKXX" then 15 27
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

776 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