Shahezad Contractor
Captain
Professor Ebrahimi
The final exam will be on 5/11/06.
![]() |
Visual Basic Tutorial |
The Mission of this web site is to help Novice Programmers. This will show you how to design programs in a simple and easy way, best of all its free and there is no advertisement.
In 1994, Dr. Alireza Ebrahimi wrote a about the novice programmers that "Why do Novice Programmers have difficulties in programming, and what are the probable cause of these errors? this study analyzes the role of Language constructs comprehension, Plan Composition, and their relationship......more
|
|
Last Update: April 26, 2006
Web Master: Syed Ahmed
Public
Class Form1 Inherits System.Windows.Forms.Form Dim hourlyrate(100), hoursworked(100), grosspay(100) As Integer Dim taxrate(100), taxamount(100), netpay(100) As Double Dim n As Integer = 0 Dim employeeid(100), fname(100), lname(100) As String#
Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer.InitializeComponent()
'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Thencomponents.Dispose()
End If End If MyBase.Dispose(disposing) 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. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents Label1 As System.Windows.Forms.Label Friend WithEvents Label2 As System.Windows.Forms.Label Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents Label3 As System.Windows.Forms.Label Friend WithEvents TextBox3 As System.Windows.Forms.TextBox Friend WithEvents TextBox4 As System.Windows.Forms.TextBox Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents TextBox5 As System.Windows.Forms.TextBox Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents TextBox6 As System.Windows.Forms.TextBox Friend WithEvents Label6 As System.Windows.Forms.Label Friend WithEvents TextBox7 As System.Windows.Forms.TextBox Friend WithEvents Label7 As System.Windows.Forms.Label Friend WithEvents TextBox8 As System.Windows.Forms.TextBox Friend WithEvents Label8 As System.Windows.Forms.Label Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Label9 As System.Windows.Forms.Label Friend WithEvents TextBox9 As System.Windows.Forms.TextBox Friend WithEvents Button3 As System.Windows.Forms.Button Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.Label1 = New System.Windows.Forms.Label Me.Label2 = New System.Windows.Forms.Label Me.TextBox2 = New System.Windows.Forms.TextBox Me.Label3 = New System.Windows.Forms.Label Me.TextBox3 = New System.Windows.Forms.TextBox Me.TextBox4 = New System.Windows.Forms.TextBox Me.Label4 = New System.Windows.Forms.Label Me.TextBox5 = New System.Windows.Forms.TextBox Me.Label5 = New System.Windows.Forms.Label Me.TextBox6 = New System.Windows.Forms.TextBox Me.Label6 = New System.Windows.Forms.Label Me.TextBox7 = New System.Windows.Forms.TextBox Me.Label7 = New System.Windows.Forms.Label Me.TextBox8 = New System.Windows.Forms.TextBox Me.Label8 = New System.Windows.Forms.Label Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.Label9 = New System.Windows.Forms.Label Me.TextBox9 = New System.Windows.Forms.TextBox Me.Button3 = New System.Windows.Forms.Button Me.GroupBox1 = New System.Windows.Forms.GroupBox Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(24, 48) Me.TextBox1.Name = "TextBox1" Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'Label1 ' Me.Label1.Location = New System.Drawing.Point(24, 32) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(72, 16) Me.Label1.TabIndex = 1 Me.Label1.Text = "Employee ID" ' 'Label2 ' Me.Label2.Location = New System.Drawing.Point(24, 80) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(64, 16) Me.Label2.TabIndex = 2 Me.Label2.Text = "First Name" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(24, 96) Me.TextBox2.Name = "TextBox2" Me.TextBox2.TabIndex = 3 Me.TextBox2.Text = "" ' 'Label3 ' Me.Label3.Location = New System.Drawing.Point(152, 80) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(64, 16) Me.Label3.TabIndex = 4 Me.Label3.Text = "Last Name" ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(152, 96) Me.TextBox3.Name = "TextBox3" Me.TextBox3.TabIndex = 5 Me.TextBox3.Text = "" ' 'TextBox4 ' Me.TextBox4.Location = New System.Drawing.Point(24, 280) Me.TextBox4.Name = "TextBox4" Me.TextBox4.TabIndex = 6 Me.TextBox4.Text = "" ' 'Label4 ' Me.Label4.Location = New System.Drawing.Point(24, 264) Me.Label4.Name = "Label4" Me.Label4.Size = New System.Drawing.Size(64, 16) Me.Label4.TabIndex = 7 Me.Label4.Text = "Gross Pay" ' 'TextBox5 ' Me.TextBox5.Location = New System.Drawing.Point(152, 280) Me.TextBox5.Name = "TextBox5" Me.TextBox5.TabIndex = 8 Me.TextBox5.Text = "" ' 'Label5 ' Me.Label5.Location = New System.Drawing.Point(152, 264) Me.Label5.Name = "Label5" Me.Label5.Size = New System.Drawing.Size(48, 16) Me.Label5.TabIndex = 9 Me.Label5.Text = "Net Pay" ' 'TextBox6 ' Me.TextBox6.Location = New System.Drawing.Point(24, 144) Me.TextBox6.Name = "TextBox6" Me.TextBox6.TabIndex = 10 Me.TextBox6.Text = "" ' 'Label6 ' Me.Label6.Location = New System.Drawing.Point(24, 128) Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(64, 16) Me.Label6.TabIndex = 11 Me.Label6.Text = "Hourly Rate" ' 'TextBox7 ' Me.TextBox7.Location = New System.Drawing.Point(24, 232) Me.TextBox7.Name = "TextBox7" Me.TextBox7.TabIndex = 12 Me.TextBox7.Text = "" ' 'Label7 ' Me.Label7.Location = New System.Drawing.Point(24, 216) Me.Label7.Name = "Label7" Me.Label7.Size = New System.Drawing.Size(56, 16) Me.Label7.TabIndex = 13 Me.Label7.Text = "Tax Rate" ' 'TextBox8 ' Me.TextBox8.Location = New System.Drawing.Point(152, 232) Me.TextBox8.Name = "TextBox8" Me.TextBox8.TabIndex = 14 Me.TextBox8.Text = "" ' 'Label8 ' Me.Label8.Location = New System.Drawing.Point(152, 216) Me.Label8.Name = "Label8" Me.Label8.Size = New System.Drawing.Size(72, 16) Me.Label8.TabIndex = 15 Me.Label8.Text = "Tax Amount" ' 'Button1 ' Me.Button1.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte)) Me.Button1.ForeColor = System.Drawing.Color.White Me.Button1.Location = New System.Drawing.Point(160, 48) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(80, 23) Me.Button1.TabIndex = 16 Me.Button1.Text = "Search By ID" ' 'Button2 ' Me.Button2.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte)) Me.Button2.ForeColor = System.Drawing.Color.White Me.Button2.Location = New System.Drawing.Point(160, 176) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(80, 23) Me.Button2.TabIndex = 17 Me.Button2.Text = "Add Record" ' 'Label9 ' Me.Label9.Location = New System.Drawing.Point(152, 128) Me.Label9.Name = "Label9" Me.Label9.Size = New System.Drawing.Size(88, 16) Me.Label9.TabIndex = 18 Me.Label9.Text = "Hours Worked" ' 'TextBox9 ' Me.TextBox9.Location = New System.Drawing.Point(152, 144) Me.TextBox9.Name = "TextBox9" Me.TextBox9.TabIndex = 19 Me.TextBox9.Text = "" ' 'Button3 ' Me.Button3.BackColor = System.Drawing.Color.FromArgb(CType(0, Byte), CType(0, Byte), CType(192, Byte)) Me.Button3.ForeColor = System.Drawing.Color.White Me.Button3.Location = New System.Drawing.Point(256, 48) Me.Button3.Name = "Button3" Me.Button3.TabIndex = 20 Me.Button3.Text = "Clear" ' 'GroupBox1 ' Me.GroupBox1.Location = New System.Drawing.Point(16, 16) Me.GroupBox1.Name = "GroupBox1" Me.GroupBox1.Size = New System.Drawing.Size(328, 296) Me.GroupBox1.TabIndex = 21 Me.GroupBox1.TabStop = False Me.GroupBox1.Text = "Shahezad's Payroll Program" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(255, Byte), CType(255, Byte)) Me.ClientSize = New System.Drawing.Size(360, 326) Me.Controls.Add(Me.Button3) Me.Controls.Add(Me.TextBox9) Me.Controls.Add(Me.Label9) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.Label8) Me.Controls.Add(Me.TextBox8) Me.Controls.Add(Me.Label7) Me.Controls.Add(Me.TextBox7) Me.Controls.Add(Me.Label6) Me.Controls.Add(Me.TextBox6) Me.Controls.Add(Me.Label5) Me.Controls.Add(Me.TextBox5) Me.Controls.Add(Me.Label4) Me.Controls.Add(Me.TextBox4) Me.Controls.Add(Me.TextBox3) Me.Controls.Add(Me.Label3) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.Label2) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.TextBox1) Me.Controls.Add(Me.GroupBox1) Me.Name = "Form1" Me.Text = "Form1" Me.ResumeLayout(False) End Sub#
End Region Private Sub GrossPayGuy() 'Grosspay is calculated heregrosspay(n) = hourlyrate(n) * hoursworked(n)
End Sub Private Sub TaxRateGuy() 'An if statement is used to calculate the taxrate If (grosspay(n) > 500) Thentaxrate(n) = 0.3
ElseIf (grosspay(n) > 200) And (grosspay(n) < 500) Thentaxrate(n) = 0.2
Else : taxrate(n) = 0.1 End If End Sub Private Sub ComputeAll() 'The information is entered here.employeeid(n) = TextBox1.Text
fname(n) = TextBox2.Text
lname(n) = TextBox3.Text
hourlyrate(n) = TextBox6.Text
hoursworked(n) = TextBox9.Text
GrossPayGuy()
TaxRateGuy()
'taxamount and net pay is calculated heretaxamount(n) = grosspay(n) * taxrate(n)
netpay(n) = grosspay(n) - taxamount(n)
'All the calculated information is displayedTextBox7.Text = taxrate(n)
TextBox8.Text = taxamount(n)
TextBox4.Text = grosspay(n)
TextBox5.Text = netpay(n)
n = n + 1
End Sub Private Sub SearchByID() Dim i As Integer For i = 0 To n - 1 If TextBox1.Text = employeeid(i) ThenTextBox2.Text = fname(i)
TextBox3.Text = lname(i)
TextBox6.Text = hourlyrate(i)
TextBox9.Text = hoursworked(i)
TextBox7.Text = taxrate(i)
TextBox8.Text = taxamount(i)
TextBox4.Text = grosspay(i)
TextBox5.Text = netpay(i)
End If Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.ClickComputeAll()
End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickSearchByID()
End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.ClickTextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox6.Text = ""
TextBox9.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
End SubEnd
Class