How to get input to switch to a second listbox after 7 numbers are entered in the first listbox?

  • Thread starter Thread starter Dslotegraaf
  • Start date Start date
D

Dslotegraaf

Guest
Hi! So I've been working on this assignment for school and I'm slightly stuck. I'm supposed to create this form to calculate average units shipped by employees. I have three different employees so three different listboxes to accept the data but only one input textbox. The form is supposed to only accept 7 numbers in the first listbox before moving onto the second listbox, getting 7 numbers there, then going to the third. But I don't know how to do that

I've tried
1 Dim students(6) As Integer
2
3 students(0) = "" &inputtextbox.Text
4 students(1) = "" &inputtextbox.Text
5 students(2) = "" &inputtextbox.Text
6 students(3) = "" &inputtextbox.Text
7 students(4) = "" &inputtextbox.Text
8 students(5) = "" &inputtextbox.Text
9 students(6) = "" &inputtextbox.Text


And
1 If Employee1.Count = 7 Then
2 If InputTextbox.Text >= 0 AndAlso InputTextbox.Text <= 1000 Then
3 Employee2.Add(InputTextbox.Text)
4 EmployeeListbox2.DataSource = Nothing
5 EmployeeListbox2.DataSource = Employee1
6 InputTextbox.Clear()
7 End If
8 End If


This is my code so now but I think something is still missing... Any help would be much appreciated
01 Dim CurrentListbox As Integer
02 Private Sub EnterButton_Click(sender As Object, e As EventArgs) Handles EnterButton.Click
03 Dim UnitsArray As String()
04 Dim output As Integer
05
06 UnitsArray = Split(InputTextbox.Text, ",")
07 For output = 1 To UnitsArray.Count
08 If output >= 1 And output <= 7 Then
09 Select Case CurrentListbox
10 Case 0 To 6
11 EmployeeListbox1.Items.Add(UnitsArray(output - 1))
12
13
14 Case 7 To 13
15 EmployeeListbox2.Items.Add(UnitsArray(output - 1))
16
17 Case 14 To 20
18 EmployeeListbox3.Items.Add(UnitsArray(output - 1))
19
20 End Select
21
22 ElseIf output = 7 Then
23 If CurrentListbox < 7 Then
24 CurrentListbox = CurrentListbox + 1
25 Else
26 ' last one - no more listboxes
27 End If
28 Exit For
29 End If
30 Next
31 InputTextbox.Text = ""
32 End Sub
33
34 Private Sub EmployeeListbox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles EmployeeListbox1.SelectedIndexChanged
35
36 End Sub
37
38 Private Sub AverageUnitsShippedByEmployeeForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
39 CurrentListbox = 1
40 EmployeeListbox1.Items.Clear()
41 EmployeeListbox2.Items.Clear()
42 EmployeeListbox3.Items.Clear()
43 End Sub

Continue reading...
 

Similar threads

Back
Top