如果value
有重复的value
,我在验证时会遇到问题。
例如,我输入了201800001
,在该value
中,另一个表中的值为3。
`201800001` = `1100`
= `1100`
= `1100`
我的代码正在运行,即使所有value
都一样,但是我想要的是如果它有重复的value
,则会自动删除其他相同的value
。
我想要结果是这样的,
`201800001` = '1100'
另一个相同的value
被删除。
到目前为止,这是我的代码。
If dgTitleList.Rows.Count = 0 Then MessageBox.Show("No records found to be generated", "No Data", MessageBoxButtons.OK, MessageBoxIcon.Information) : Exit Sub
If cboNTS.Text = dgTitleList.CurrentRow.Cells(4).Value.ToString() Then
MessageBox.Show("The Title Status is already " + dgTitleList.CurrentRow.Cells(4).Value.ToString() + ".")
Exit Sub
End If
Dim IsWip As String
Dim rdSeq, wipSeq, listSeq, tnList, eno, epebid As String
tnList = ""
eno = tnList
rdSeq = tnList
wipSeq = tnList
If txtRSUNO.Text = "" Then MessageBox.Show("Please input RSU number", "No RSU Number", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) : Exit Sub
If cboNTS.Text = "" Then MessageBox.Show("Please choose new title status", "No RSU Number", MessageBoxButtons.OK, MessageBoxIcon.Asterisk) : Exit Sub
For i = 0 To dgTitleList.Rows.Count - 1
If eno.Contains(dgTitleList("dcEPEBENO", i).Value) = False Then
eno &= If(eno = Nothing, "", ",") & dgTitleList("dcEPEBENO", i).Value
End If
epebid = dgTitleList.CurrentRow.Cells(1).Value.ToString()
Dim stat As String = dgTitleList("dcIsWIP", i).Value
Dim dtno As String = dgTitleList("dcTitleNo", i).Value
Dim dseq As String = dgTitleList("dcTitleSeq", i).Value
tnList &= If(tnList = Nothing, "", ",") & If(tnList.Contains(dtno) = True, "", dtno)
If stat = "N" Then
If rdSeq.Contains(dtno) = True Then Continue For
rdSeq &= If(rdSeq = "", "", ",") & dseq
Else
If wipSeq.Contains(dtno) = True Then Continue For
wipSeq &= If(wipSeq = "", "", ",") & dseq
End If
Next
If chkIsWIP.Checked = True Then
IsWip = "PHILARIS_RD_WIP..MS_Title_List"
Else
IsWip = "MS_Title_List"
End If
listSeq = rdSeq & If(rdSeq = "" Or wipSeq = "", "", ",") & wipSeq
Dim RSUs As New List(Of String)
RSUs.Add("RSU-" & txtRoD.Text & "-" & txtRSUNO.Text)
CreateFolder(RSUs(0))
Dim script As String = SetMainHeader(getScriptVersion("Tag Title Status"), txtRoD.Text, txtRSUNO.Text, epebid, "10", "UPDATE TITLE STATUS", "PHILARIS_RD")
script &= returnScriptGenerated("TagTitleStatus", "Header.txt", txtRSUNO.Text & "|" & eno.Replace(",", "','") & "|" & bookType & "|" & tnList.Replace(",", "','"))
script &= If(rdSeq = "", "", returnScriptGenerated("TagTitleStatus", "HistRD.txt", ""))
script &= If(wipSeq = "", "", returnScriptGenerated("TagTitleStatus", "HistWIP.txt", ""))
script &= returnScriptGenerated("TagTitleStatus", "break2.txt", "")
script &= If(rdSeq = "", "", returnScriptGenerated("TagTitleStatus", "UpdateRD.txt", cboNTS.Text & "|" & rdSeq))
script &= If(wipSeq = "", "", returnScriptGenerated("TagTitleStatus", "UpdateWIP.txt", cboNTS.Text & "|" & wipSeq))
script &= returnScriptGenerated("TagTitleStatus", "Footer.txt", IsWip & "|" & bookType & "|" & txtRoD.Text & "|" & eno & "|" & listSeq & "|" & txtRSUNO.Text & "|" & "Update Title Status|")
ScriptWriter("RSU-" & txtRoD.Text & "-" & txtRSUNO.Text, script)
DBAexecScripts(RSUs, "RD_" & txtRoD.Text & ",RD_" & txtRoD.Text)
This is the result when i run the program and enter a value.
如果我输入的For Loop
彼此不同,则value
起作用,并且如果value
相同,则value
也起作用。
现在我说的是验证相同的db.collection.find({"comments":{$elemMatch:{creator:"name"}}})
。
答案 0 :(得分:1)
您很可能会受益于Dictionary
或HashSet
。
Dim valueHash = New HashSet(Of String)();
For i = 0 To dgTitleList.Rows.Count - 1
Dim currentVal As String = GetStringExample(i)
If Not valueHash.Contains(currentVal) Then
valueHash.Add(currentVal)
End If
Next
以上是一个非常简单的示例,因为我无法轻松地遵循您发布的代码。如果您可以稍微拆分一下代码并实现Single Responsbility Principle,则使用它会容易得多。