在我正在处理的作业中捕获重复项时遇到了一些麻烦。
任务是田径比赛经理。从文本文件中读取时间,然后为从文本文件加载的每次时间输入一个围兜号码(也就是时间文本文件中有多少行)
然后,号码布号码和时间会按照输入的顺序进行同步。要求是必须使用输入框一次输入一个号码布号码。每次输入书目号码时,都会将其加载到名为 lstBibs 的列表框中。
我在使用输入框方面的经验有限,并且到目前为止 我为检查重复项所做的任何尝试都在运行时被忽略了。我也不确定我会在哪里放置一个循环来检查输入框中的重复项。以下是我到目前为止的代码。
Dim i As Integer = 0
Dim Bibno As Integer = 0
Dim strrow As String = ""
Dim count As Integer = 0
Dim errorCount1 As Integer = 0
'Reads through the number of rows in the Time Text File.
'The Number of rows we have in the text file corresponds to the number
'of bib numbers we need. Thus the input box will loop through bib
'numbers until
'we reach the amount of loaded times
Try
For Each item In lstTimeEntry.Items
i += 1
For Bibno = 1 To i
count += 1
Bibno = InputBox("Enter Bib #" & count)
lstBibs.Items.Add(count & " - " & Bibno)
btnSyncTimesBibs.Enabled = True
Next
Next
Catch ex As Exception
'Catches any invalid data that isnt a number
MsgBox("Invalid Input, Please Try Again", , "Error")
lstBibs.Items.Clear()
btnSyncTimesBibs.Enabled = False
End Try
所以我假设我必须使用一个 for 循环来检查每个列表框项是否重复,我只是不确定这个循环相对于上面的代码会去哪里。
非常感谢任何和所有帮助。谢谢你。