Question

In: Computer Science

Using ASP.NET create an Age Calculator; which can determine an age according to a given date...

Using ASP.NET create an Age Calculator; which can determine an age according to a given date of birth. The calculated age will be displayed in years, months, weeks, days, hours, minutes, and seconds. How old are you in years, or months, or weeks, or days, or minutes, or seconds. The only input parameter is the birth date then the user will know his age

Solutions

Expert Solution

Design

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="Agecalculator1.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 100%;
}
.auto-style2 {
width: 233px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
  
<table class="auto-style1">
<tr>
<td class="auto-style2">
<asp:Label ID="Label1" runat="server" Text="Enter the Date of Birth ."></asp:Label>
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server" Width="359px"></asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="calander.png" Height="36px" Width="33px"/>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999" CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Height="180px" Width="200px">
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<NextPrevStyle VerticalAlign="Bottom" />
<OtherMonthDayStyle ForeColor="#808080" />
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<SelectorStyle BackColor="#CCCCCC" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<WeekendDayStyle BackColor="#FFFFCC" />
</asp:Calendar>
</td>
</tr>
<tr>
<td class="auto-style2">&nbsp;</td>
<td>
<asp:Label ID="lblage" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td class="auto-style2">&nbsp;</td>
<td>
<asp:Button ID="btnCalculate" runat="server" Text="Calculate" Width="160px" />
</td>
</tr>
</table>
  
</div>
</form>
</body>
</html>

DesignView

Coding

Public Class WebForm1
Inherits System.Web.UI.Page
Dim dob As Date
Dim days, month, year, hour, minutes, second As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Calendar1.Visible = False
End Sub

Protected Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
dob = Convert.ToDateTime(TextBox1.Text)
year = DateDiff(DateInterval.Year, dob, Now) ''calculate year here
month = DateDiff(DateInterval.Month, dob, Now) 'calculate month here
days = DateDiff(DateInterval.Day, dob, Now) 'calculate days here
hour = DateDiff(DateInterval.Hour, dob, Now) 'calculate hour here
minutes = DateDiff(DateInterval.Minute, dob, Now) 'calculate Minute here
second = DateDiff(DateInterval.Second, dob, Now) 'calculate Second here
lblage.Text = "Year ::" + Convert.ToString(year) + " Months ::" + Convert.ToString(month) + " Days ::" + days.ToString + " Hour :- " + hour.ToString + " Minutes :-" + minutes.ToString + " Second " + second.ToString
''output display here
End Sub

Protected Sub ImageButton1_Click(sender As Object, e As ImageClickEventArgs) Handles ImageButton1.Click
If Calendar1.Visible = False Then
Calendar1.Visible = True
Else
Calendar1.Visible = False
End If

End Sub

Protected Sub Calendar1_SelectionChanged(sender As Object, e As EventArgs) Handles Calendar1.SelectionChanged
dob = Calendar1.SelectedDate.ToString("MM/dd/yyyy hh:mm:ss")
TextBox1.Text = dob.ToString
End Sub
End Class

Output

if you still have any Problem regarding this question please comment and if you like my code please appreciate me by thumbs up thank you.........


Related Solutions

Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store data...
Create an ASP.Net Website using Visual Studio with Visual Basic.Net: Create a simple calculator that has...
Create an ASP.Net Website using Visual Studio with Visual Basic.Net: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store...
Create a new website using C# & ASP.Net in Visual Studio: 1. Create a web page...
Create a new website using C# & ASP.Net in Visual Studio: 1. Create a web page to access a database and display the data from a table by providing an SQL statement. Create the page with these requirements:     create label, textbox and button     the textbox will capture the SQL statement     the button will process the statement and display the results 2. Add necessary data access pages to your project. 3. Display the data in Gridview
Create a calculator in java without using the math library which converts an integer into a...
Create a calculator in java without using the math library which converts an integer into a hexadecimal number.
Create a new ASP.NET using MVC. Set the application to SSL Enabled Implement an external login...
Create a new ASP.NET using MVC. Set the application to SSL Enabled Implement an external login provider Facebook.
In this project you will create a basic console based calculator program. The calculator can operate...
In this project you will create a basic console based calculator program. The calculator can operate in two modes: Standard and Scientific modes. The Standard mode will allow the user to perform the following operations: (+, -, *, /) add, subtract, multiply, and divide The Scientific mode will allow the user to perform the same functionality as the Standard add, subtract, multiply, and divide (+, -, *, / ) plus the following: sin x, cos x, tan x. (sin x,...
Using Java Write a simple calculator which can add, subtract, multiply, and divide. Here are the...
Using Java Write a simple calculator which can add, subtract, multiply, and divide. Here are the specifications for the calculator: The calculator has one “accumulator”, which holds the result of all prior calculations. The calculator is set to 0.0 when the calculator is turned on (i.e., instantiated). On the console, the user then enters an operator (+, -, *, or /) and a number. Your console will then apply the operator and operand to the number in the accumulator, and...
create scientific calculator using java language with OOP rule and interfaces.
create scientific calculator using java language with OOP rule and interfaces.
create calculator standard using java language with OOP rule and interfaces.
create calculator standard using java language with OOP rule and interfaces.
Java Program using Netbeans IDE Create class Date with the following capabilities: a. Output the date...
Java Program using Netbeans IDE Create class Date with the following capabilities: a. Output the date in multiple formats, such as MM/DD/YYYY June 14, 1992 DDD YYYY b. Use overloaded constructors to create Date objects initialized with dates of the formats in part (a). In the first case the constructor should receive three integer values. In the second case it should receive a String and two integer values. In the third case it should receive two integer values, the first...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT