You work for a Marketing firm called SA Modern Suppliers. Your Purchasing Manager has asked you to write a VB Application that will allow users to create a flexible Suppliers List to which Suppliers can be added and removed as well as enable the user to clear the entire Suppliers List when it is no longer needed.
Allow the user to enter the Supplier name in the text box.
When the user clicks on the Add button the program should add the Supplier to
the list.
When the user selects a Supplier from the list and clicks the remove button, the
program should remove the selected Supplier from the list.
When the user clicks the Clear button, the program should clear the entire
Suppliers List.
When the user clicks on Exit, the application should close.
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmSAModernSuppliers
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.btnAdd = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.txtSupplierName = New System.Windows.Forms.TextBox()
Me.btnRemove = New System.Windows.Forms.Button()
Me.lstNames = New System.Windows.Forms.ListBox()
Me.btnClear = New System.Windows.Forms.Button()
Me.btnExit = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
'btnAdd
'
Me.btnAdd.Location = New System.Drawing.Point(46, 203)
Me.btnAdd.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.btnAdd.Name = "btnAdd"
Me.btnAdd.Size = New System.Drawing.Size(93, 35)
Me.btnAdd.TabIndex = 0
Me.btnAdd.Text = "Add"
Me.btnAdd.UseVisualStyleBackColor = True
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(42, 29)
Me.Label1.Margin = New System.Windows.Forms.Padding(4, 0, 4, 0)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(218, 20)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Ente enter the supplier name:"
'
'txtSupplierName
'
Me.txtSupplierName.Location = New System.Drawing.Point(46, 64)
Me.txtSupplierName.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.txtSupplierName.Name = "txtSupplierName"
Me.txtSupplierName.Size = New System.Drawing.Size(214, 26)
Me.txtSupplierName.TabIndex = 2
'
'btnRemove
'
Me.btnRemove.Location = New System.Drawing.Point(167, 203)
Me.btnRemove.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.btnRemove.Name = "btnRemove"
Me.btnRemove.Size = New System.Drawing.Size(93, 35)
Me.btnRemove.TabIndex = 0
Me.btnRemove.Text = "Remove"
Me.btnRemove.UseVisualStyleBackColor = True
'
'lstNames
'
Me.lstNames.FormattingEnabled = True
Me.lstNames.ItemHeight = 20
Me.lstNames.Location = New System.Drawing.Point(46, 98)
Me.lstNames.Name = "lstNames"
Me.lstNames.Size = New System.Drawing.Size(214, 84)
Me.lstNames.TabIndex = 3
'
'btnClear
'
Me.btnClear.Location = New System.Drawing.Point(46, 248)
Me.btnClear.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.btnClear.Name = "btnClear"
Me.btnClear.Size = New System.Drawing.Size(93, 35)
Me.btnClear.TabIndex = 0
Me.btnClear.Text = "Clear"
Me.btnClear.UseVisualStyleBackColor = True
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(167, 248)
Me.btnExit.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.btnExit.Name = "btnExit"
Me.btnExit.Size = New System.Drawing.Size(93, 35)
Me.btnExit.TabIndex = 0
Me.btnExit.Text = "Exit"
Me.btnExit.UseVisualStyleBackColor = True
'
'Form1
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(301, 307)
Me.Controls.Add(Me.lstNames)
Me.Controls.Add(Me.txtSupplierName)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.btnRemove)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.btnClear)
Me.Controls.Add(Me.btnAdd)
Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(204, Byte))
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Margin = New System.Windows.Forms.Padding(4, 5, 4, 5)
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Form1"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "SA Modern Suppliers"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents btnAdd As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents txtSupplierName As System.Windows.Forms.TextBox
Friend WithEvents btnRemove As System.Windows.Forms.Button
Friend WithEvents lstNames As System.Windows.Forms.ListBox
Friend WithEvents btnClear As System.Windows.Forms.Button
Friend WithEvents btnExit As System.Windows.Forms.Button
End Class
Public Class frmSAModernSuppliers
''' <summary>
''' When the user clicks on the Add button the program should add the Supplier to the list.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
'Allow the user to enter the Supplier name in the text box.
lstNames.Items.Add(txtSupplierName.Text)
txtSupplierName.Text = ""
End Sub
''' <summary>
''' When the user selects a Supplier from the list and clicks the remove button, the
''' program should remove the selected Supplier from the list.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnRemove_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRemove.Click
If lstNames.SelectedIndex <> -1 Then
lstNames.Items.RemoveAt(lstNames.SelectedIndex)
End If
End Sub
''' <summary>
''' When the user clicks the Clear button, the program should clear the entire Suppliers List
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
lstNames.Items.Clear()
End Sub
''' <summary>
''' When the user clicks on Exit, the application should close.
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
Comments
Leave a comment