我将用户输入的数据从列表中的文本框和组合框存储为单个字符串,然后在调用时检索该特定数据。
Public Class BMGSwimmingSports
'Creates a list
Dim Participants As List(Of String) = New List(Of String)
Private Sub btnAddStudent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddStudent.Click
'Stores inputed data from text boxes and combo boxes in a list then clears the text and combo boxes
Participants.Add(txtGivenName.Text + ", " + txtSurname.Text + ", " + cmbGender.Text + ", " + cmbYearLevel.Text + ", " + cmbEvent.Text + ".")
txtGivenName.Text = ""
txtSurname.Text = ""
cmbEvent.Text = ""
cmbGender.Text = ""
cmbYearLevel.Text = ""
End Sub
Private Sub btnReturn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReturn.Click
'Returns the user to the menu page
frmMenu.Show()
Me.Hide()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'Clears the participants lable when data will be retrived to.
lblParticpants.Text = ""
End Sub
Private Sub cmbEventList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbEventList.SelectedIndexChanged
'Takes ----- out of list and displays it in a lable.
If Participants.Contains("Freestyle") Then
End If
End Sub
End Class
当我在cmbEventList中选择一个特定项目时,我需要程序搜索列表并显示包含所述输入的数据(如果它包含“freestyle”,我在声明的代码中示例)
答案 0 :(得分:0)
您应该创建一个循环并在那里进行比较:
For Each part As String in Participants
If part.Contains("Freestyle") Then
'' do something with "part" object
End If
Next