001.
Imports
System.Windows.Forms
002.
003.
Public
Class
Form1
004.
Inherits
System.Windows.Forms.Form
005.
006.
Public
Sub
New
()
007.
MyBase
.
New
()
008.
InitializeComboBox()
009.
InitializeTextBox()
010.
Me
.Label1 =
New
System.Windows.Forms.Label
011.
Me
.SuspendLayout()
012.
Me
.Label1.Location =
New
System.Drawing.Point(8, 24)
013.
Me
.Label1.Name =
"Label1"
014.
Me
.Label1.Size =
New
System.Drawing.Size(120, 32)
015.
Me
.Label1.TabIndex = 1
016.
Me
.Label1.Text =
"Use drop-down to choose a name:"
017.
Me
.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
018.
Me
.ClientSize =
New
System.Drawing.Size(292, 266)
019.
Me
.Controls.Add(
Me
.Label1)
020.
Me
.Name =
"Form1"
021.
Me
.Text =
"Form1"
022.
Me
.ResumeLayout(
False
)
023.
End
Sub
024.
025.
Shared
Sub
Main()
026.
Application.Run(
New
Form1)
027.
End
Sub
028.
029.
030.
Friend
WithEvents
Label1
As
System.Windows.Forms.Label
031.
032.
033.
034.
035.
036.
037.
038.
Friend
WithEvents
TextBox1
As
System.Windows.Forms.TextBox
039.
040.
Private
Sub
InitializeTextBox()
041.
Me
.TextBox1 =
New
System.Windows.Forms.TextBox
042.
Me
.TextBox1.ScrollBars = ScrollBars.Vertical
043.
Me
.TextBox1.Location =
New
System.Drawing.Point(64, 128)
044.
Me
.TextBox1.Multiline =
True
045.
Me
.TextBox1.Name =
"TextBox1"
046.
Me
.TextBox1.
ReadOnly
=
True
047.
Me
.TextBox1.Size =
New
System.Drawing.Size(184, 120)
048.
Me
.TextBox1.TabIndex = 4
049.
Me
.TextBox1.Text =
"Employee and Number of Awards:"
050.
Me
.Controls.Add(
Me
.TextBox1)
051.
End
Sub
052.
053.
054.
055.
Friend
WithEvents
ComboBox1
As
System.Windows.Forms.ComboBox
056.
057.
058.
059.
060.
Private
Sub
InitializeComboBox()
061.
Me
.ComboBox1 =
New
System.Windows.Forms.ComboBox
062.
Dim
employees()
As
String
=
New
String
() {
"Hamilton, David"
, _
063.
"Hensien, Kari"
,
"Hammond, Maria"
,
"Harris, Keith"
, _
064.
"Henshaw, Jeff D."
,
"Hanson, Mark"
,
"Harnpadoungsataya, Sariya"
, _
065.
"Harrington, Mark"
,
"Harris, Keith"
,
"Hartwig, Doris"
, _
066.
"Harui, Roger"
,
"Hassall, Mark"
,
"Hasselberg, Jonas"
, _
067.
"Harnpadoungsataya, Sariya"
,
"Henshaw, Jeff D."
,
"Henshaw, Jeff D."
, _
068.
"Hensien, Kari"
,
"Harris, Keith"
,
"Henshaw, Jeff D."
, _
069.
"Hensien, Kari"
,
"Hasselberg, Jonas"
,
"Harrington, Mark"
, _
070.
"Hedlund, Magnus"
,
"Hay, Jeff"
,
"Heidepriem, Brandon D."
}
071.
072.
ComboBox1.Items.AddRange(employees)
073.
Me
.ComboBox1.Location =
New
System.Drawing.Point(136, 32)
074.
Me
.ComboBox1.IntegralHeight =
False
075.
Me
.ComboBox1.MaxDropDownItems = 5
076.
Me
.ComboBox1.DropDownStyle = ComboBoxStyle.DropDown
077.
Me
.ComboBox1.Name =
"ComboBox1"
078.
Me
.ComboBox1.Size =
New
System.Drawing.Size(136, 81)
079.
Me
.ComboBox1.TabIndex = 0
080.
Me
.Controls.Add(
Me
.ComboBox1)
081.
End
Sub
082.
083.
084.
085.
086.
087.
088.
089.
090.
091.
092.
093.
Private
Sub
ComboBox1_SelectedIndexChanged(
ByVal
sender
As
Object
, _
094.
ByVal
e
As
System.EventArgs)
Handles
ComboBox1.SelectedIndexChanged
095.
096.
Dim
comboBox
As
comboBox =
CType
(sender, comboBox)
097.
098.
099.
100.
Dim
selectedEmployee =
CType
(ComboBox1.SelectedItem,
String
)
101.
102.
Dim
count
As
Integer
= 0
103.
Dim
resultIndex
As
Integer
= -1
104.
105.
106.
107.
resultIndex = ComboBox1.FindStringExact(ComboBox1.SelectedItem)
108.
109.
110.
111.
112.
113.
While
(resultIndex <> -1)
114.
ComboBox1.Items.RemoveAt(resultIndex)
115.
count += 1
116.
resultIndex = ComboBox1.FindStringExact _
117.
(selectedEmployee, resultIndex)
118.
End
While
119.
120.
121.
TextBox1.Text = TextBox1.Text & Microsoft.VisualBasic.vbCrLf _
122.
& selectedEmployee &
": "
& count
123.
End
Sub
124.
125.
End
Class