UI:
Provided Code:
Public Class Form1
Private Sub btnExit_Click(sender As Object,
e As EventArgs) Handles btnExit.Click
Me.Close()
End Sub
Private Sub btnCalculateDueDays_Click(sender As Object, e As EventArgs) Handles btnCalculateDueDays.Click
End Sub
End Class
VB Code:
File: Form1.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
_
Partial Class Form1
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the
component list.
<System.Diagnostics.DebuggerNonUserCode()>
_
Protected Overrides Sub Dispose(ByVal disposing
As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub
'Required by the Windows Form Designer
Private components As
System.ComponentModel.IContainer
'NOTE: The following procedure is required by
the Windows Form Designer
'It can be modified using the Windows Form
Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()>
_
Private Sub InitializeComponent()
Me.Label1 = New
System.Windows.Forms.Label()
Me.Label2 = New
System.Windows.Forms.Label()
Me.txtFutureDate = New
System.Windows.Forms.TextBox()
Me.txtBirthDate = New
System.Windows.Forms.TextBox()
Me.btnCalculateDueDays =
New System.Windows.Forms.Button()
Me.btnCalculateAge = New
System.Windows.Forms.Button()
Me.btnExit = New
System.Windows.Forms.Button()
Me.SuspendLayout()
'
'Label1
'
Me.Label1.AutoSize =
True
Me.Label1.Location = New
System.Drawing.Point(27, 31)
Me.Label1.Name =
"Label1"
Me.Label1.Size = New
System.Drawing.Size(98, 13)
Me.Label1.TabIndex =
0
Me.Label1.Text = "Enter
a future date:"
'
'Label2
'
Me.Label2.AutoSize =
True
Me.Label2.Location = New
System.Drawing.Point(27, 61)
Me.Label2.Name =
"Label2"
Me.Label2.Size = New
System.Drawing.Size(88, 13)
Me.Label2.TabIndex =
1
Me.Label2.Text = "Enter
a birthdate:"
'
'txtFutureDate
'
Me.txtFutureDate.Location = New System.Drawing.Point(131, 28)
Me.txtFutureDate.Name =
"txtFutureDate"
Me.txtFutureDate.Size =
New System.Drawing.Size(100, 20)
Me.txtFutureDate.TabIndex = 2
'
'txtBirthDate
'
Me.txtBirthDate.Location
= New System.Drawing.Point(131, 58)
Me.txtBirthDate.Name =
"txtBirthDate"
Me.txtBirthDate.Size =
New System.Drawing.Size(100, 20)
Me.txtBirthDate.TabIndex
= 3
'
'btnCalculateDueDays
'
Me.btnCalculateDueDays.Location = New System.Drawing.Point(258,
28)
Me.btnCalculateDueDays.Name = "btnCalculateDueDays"
Me.btnCalculateDueDays.Size = New System.Drawing.Size(173,
23)
Me.btnCalculateDueDays.TabIndex = 4
Me.btnCalculateDueDays.Text = "Calculate Due Days"
Me.btnCalculateDueDays.UseVisualStyleBackColor = True
'
'btnCalculateAge
'
Me.btnCalculateAge.Location = New System.Drawing.Point(258,
58)
Me.btnCalculateAge.Name
= "btnCalculateAge"
Me.btnCalculateAge.Size
= New System.Drawing.Size(173, 23)
Me.btnCalculateAge.TabIndex = 5
Me.btnCalculateAge.Text
= "Calculate Age"
Me.btnCalculateAge.UseVisualStyleBackColor = True
'
'btnExit
'
Me.btnExit.Location =
New System.Drawing.Point(258, 120)
Me.btnExit.Name =
"btnExit"
Me.btnExit.Size = New
System.Drawing.Size(173, 23)
Me.btnExit.TabIndex =
6
Me.btnExit.Text =
"Exit"
Me.btnExit.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions =
New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode =
System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New
System.Drawing.Size(538, 171)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnCalculateAge)
Me.Controls.Add(Me.btnCalculateDueDays)
Me.Controls.Add(Me.txtBirthDate)
Me.Controls.Add(Me.txtFutureDate)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.Label1)
Me.Name = "Form1"
Me.Text = "Date
Handling"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Label1 As
System.Windows.Forms.Label
Friend WithEvents Label2 As
System.Windows.Forms.Label
Friend WithEvents txtFutureDate As
System.Windows.Forms.TextBox
Friend WithEvents txtBirthDate As
System.Windows.Forms.TextBox
Friend WithEvents btnCalculateDueDays As
System.Windows.Forms.Button
Friend WithEvents btnCalculateAge As
System.Windows.Forms.Button
Friend WithEvents btnExit As
System.Windows.Forms.Button
End Class
File: Form1.vb
Public Class Form1
' Calculate due days button click event
handler
Private Sub btnCalculateDueDays_Click(ByVal
sender As System.Object, ByVal e As System.EventArgs) Handles
btnCalculateDueDays.Click
' Checking
dates
If
IsDate(txtFutureDate.Text) Then
' Calculating due days
Dim curDate, futDate As Date
' Holding current date
curDate = Date.Now
' Holding future date
futDate = Convert.ToDateTime(txtFutureDate.Text)
' Calculating due days
Dim dueDays As Integer
dueDays = (futDate - curDate).Days
' Displaying in message box
MessageBox.Show("Current date: " & curDate.ToString("d") &
vbNewLine & "Future date: " & futDate.ToString("d") &
vbNewLine & vbNewLine & "Days until due: " &
dueDays.ToString())
Else
MessageBox.Show("Invalid Future Date")
End If
End Sub
' Calculate Age button click event
handler
Private Sub btnCalculateAge_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs) Handles
btnCalculateAge.Click
' Checking
dates
If
IsDate(txtBirthDate.Text) Then
' Calculating due days
Dim curDate, birDate As Date
' Holding current date
curDate = Date.Now
' Holding future date
birDate = Convert.ToDateTime(txtBirthDate.Text)
' Calculating age in years
Dim age As Integer
age = DateDiff(DateInterval.Year, birDate, curDate)
' Displaying in message box
MessageBox.Show("Current date: " & curDate.ToString("d") &
vbNewLine & "Birth date: " & birDate.ToString("d") &
vbNewLine & vbNewLine & "Age: " & age.ToString())
Else
MessageBox.Show("Invalid Future Date")
End If
End Sub
' Exit button click event
Private Sub btnExit_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnExit.Click
Application.Exit()
End Sub
End Class
______________________________________________________________________________
Sample Run:
UI: Provided Code: Public Class Form1 Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click...
Public Class Form1 Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click Dim room As Double 'Assigns room as double Dim rate As Double 'Assigns rate as double Dim room2 As Double 'Assigns room as double Dim overallRate As Double 'Assigns overall as double Dim a As Integer 'Assign a as an integer For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors With...
Using Microsoft Visual Studio C# In this lab assignment, you'll write code that parses an email address and formats the ci and zip code portion of an address. String Handling Email: [email protected] Parse City: Fresno State: ca Zp code: 93722 Format ให้ 2 Parsed String Formatted String User name: anne Domain name: murach.comm City, State, Zip: Fresno, CA 93722 OK OK Create a new Windows Forms Application named StringHandling and build the form as shown above. 1. Add code to...
Project 10-1 Convert lengths In this assignment, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: From To Conversion Miles - Kilometers: 1 mile = 1.6093 kilometers Kilometers - Miles: 1 kilometer = 0.6214 miles Feet - Meters: 1 foot = 0.3048 meters Meters - Feet: 1 meter = 3.2808 feet Inches - Centimeters: 1 inch = 2.54 centimeters Centimeters - Inches: 1...
In this exercise, you’ll add code to a form that converts the value the user enters based on the selected conversion type. The application should handle the following conversions: 1. Open the Conversions project. Display the code for the form, and notice the rectangular array whose rows contain the value to be displayed in the combo box, the text for the labels that identify the two text boxes, and the multiplier for the conversion as shown above. Note: An array...
Visual Basic: Create an application that simulates a tic tac toe game. The form uses 9 large labels to display the x's and o's. The application should use a two dimensional integer array to simulate the game board in memory. When the user clicks the "New Game" button the application should step throguh the array storing a random number of 0 to 1 in each element. The numer 0 represent the letter o and the number 1 reprsents the letter...