所以我买了一台新的笔记本电脑,并帮助我决定我想出了一个积分系统。我制作了一个应用程序来帮助计算,它由一系列复选框组成,这些复选框具有不同类别的组件等(CPU、RAM 等)的不同选项。他们根据他们的表现获得积分。我有几行代码可以检查每个类别是否选择了多个组件。如果超过 1 个,则会弹出一个消息框,告诉用户然后重置选项。但是,第一次执行后,消息框会出现两次。
错误视频:https ://imgur.com/a/D9WSVO5
这是我的第一个 vb.net 独奏 GUI 程序,所以请善待。
非常感谢, :)
Public Class Form1
Dim IS_R54500 As Boolean = False
Dim IS_R53500 As Boolean = False
Dim IS_R34300 As Boolean = False
Dim IS_Gb4 As Boolean = False
Dim IS_Gb8 As Boolean = False
Dim IS_Screen14 As Boolean = False
Dim IS_Screen15 As Boolean = False
Dim IS_SSD128 As Boolean = False
Dim IS_SSD256 As Boolean = False
Dim IS_SSD512 As Boolean = False
Dim IS_USBA As Integer = 0
Dim IS_USBC As Integer = 0
Dim IS_HDMI As Integer = 0
Dim IS_DP As Integer = 0
Dim Total As Integer = 0
Public Sub R54500_CheckedChanged(sender As Object, e As EventArgs) Handles R54500.CheckedChanged
IS_R54500 = True
End Sub
Public Sub R53500_CheckedChanged(sender As Object, e As EventArgs) Handles R53500.CheckedChanged
IS_R53500 = True
End Sub
Public Sub R34300_CheckedChanged(sender As Object, e As EventArgs) Handles R34300.CheckedChanged
IS_R34300 = True
End Sub
Public Sub Gb4_CheckedChanged(sender As Object, e As EventArgs) Handles Gb4.CheckedChanged
IS_Gb4 = True
End Sub
Public Sub Gb8_CheckedChanged(sender As Object, e As EventArgs) Handles Gb8.CheckedChanged
IS_Gb8 = True
End Sub
Public Sub Screen14_CheckedChanged(sender As Object, e As EventArgs) Handles Screen14.CheckedChanged
IS_Screen14 = True
End Sub
Public Sub Screen15_CheckedChanged(sender As Object, e As EventArgs) Handles Screen15.CheckedChanged
IS_Screen15 = True
End Sub
Public Sub SSD128_CheckedChanged(sender As Object, e As EventArgs) Handles SSD128.CheckedChanged
IS_SSD128 = True
End Sub
Public Sub SSD256_CheckedChanged(sender As Object, e As EventArgs) Handles SSD256.CheckedChanged
IS_SSD256 = True
End Sub
Public Sub SSD512_CheckedChanged(sender As Object, e As EventArgs) Handles SSD512.CheckedChanged
IS_SSD512 = True
End Sub
Public Sub USBA_TextChanged(sender As Object, e As EventArgs) Handles USBA.TextChanged
IS_USBA = USBA.Text()
End Sub
Public Sub USBC_TextChanged(sender As Object, e As EventArgs) Handles USBC.TextChanged
IS_USBC = USBC.Text()
End Sub
Public Sub HDMI_TextChanged(sender As Object, e As EventArgs) Handles HDMI.TextChanged
IS_HDMI = HDMI.Text()
End Sub
Public Sub DP_TextChanged(sender As Object, e As EventArgs) Handles DP.TextChanged
IS_DP = DP.Text()
End Sub
Public Sub Results_Click(sender As Object, e As EventArgs) Handles Results.Click
Results.Text = CStr(Total)
End Sub
Public Sub Calculate_Click(sender As Object, e As EventArgs) Handles Calculate.Click
Total = 0
If IS_R54500 And IS_R53500 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_R54500 = False
IS_R53500 = False
R54500.CheckState = CheckState.Unchecked
R53500.CheckState = CheckState.Unchecked
End If
If IS_R54500 And IS_R34300 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_R54500 = False
IS_R34300 = False
R54500.CheckState = CheckState.Unchecked
R34300.CheckState = CheckState.Unchecked
End If
If IS_R53500 And IS_R34300 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_R53500 = False
IS_R34300 = False
R53500.CheckState = CheckState.Unchecked
R34300.CheckState = CheckState.Unchecked
End If
If IS_Gb8 And IS_Gb4 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_Gb4 = False
IS_Gb8 = False
Gb4.CheckState = CheckState.Unchecked
Gb8.CheckState = CheckState.Unchecked
End If
If IS_Screen14 And IS_Screen15 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_Screen14 = False
IS_Screen15 = False
Screen14.CheckState = CheckState.Unchecked
Screen15.CheckState = CheckState.Unchecked
End If
If IS_SSD128 And IS_SSD256 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_SSD128 = False
IS_SSD256 = False
SSD128.CheckState = CheckState.Unchecked
SSD256.CheckState = CheckState.Unchecked
End If
If IS_SSD128 And IS_SSD512 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_SSD128 = False
IS_SSD512 = False
SSD128.CheckState = CheckState.Unchecked
SSD512.CheckState = CheckState.Unchecked
End If
If IS_SSD512 And IS_SSD256 = True Then
MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
IS_SSD512 = False
IS_SSD256 = False
SSD512.CheckState = CheckState.Unchecked
SSD256.CheckState = CheckState.Unchecked
End If
If IS_R54500 = True Then
Total += 3
End If
If IS_R53500 = True Then
Total += 2
End If
If IS_R34300 = True Then
Total += 1
End If
If IS_Gb8 = True Then
Total += 2
End If
If IS_Gb4 = True Then
Total += 1
End If
If IS_Screen14 = True Then
Total += 1
End If
If IS_Screen15 = True Then
Total += 2
End If
If IS_SSD128 = True Then
Total += 1
End If
If IS_SSD256 = True Then
Total += 2
End If
If IS_SSD512 = True Then
Total += 3
End If
Total += CInt(IS_USBA)
Total += CInt(IS_USBC)
Total += CInt(IS_HDMI)
Total += CInt(IS_DP)
''MessageBox.Show("There is more than one option chosen in a certain category." & vbCrLf & "Please fix this error and then try again.", "Error")
Results.Text = Total
End Sub
结束类