我可以调用的方法中有一个“if”或“case”语句。我有 "Flag" 变量作为 public status。它的循环/运行两次很疯狂,所以导致有重复的命令,在这种情况下,我在数据库上有重复的数据。
Public Sub compartment1(ByVal exec As Boolean)
Try
If exec = True Then
Select Case FlagMark
Case 1
Insert database execute command
Case 2
another command
End Select
ElseIf exec = False Then
End If
Catch ex As Exception
End Try
End Sub
这是我的按钮命令
Private Sub cmd_confirm_Click(sender As Object, e As EventArgs) Handles cmd_confirm.Click
If pCheck2.Checked = True Then
FlagMark = 1
compartment1(True)
End If
End Sub
方法“Compartment1”运行了两次,看起来像循环,所以我有重复的数据或单个命令的重复。它可以只运行一次吗?