📄 背包问题.txt
字号:
Dim a1 As Integer
Dim a2 As Integer
Dim a3 As Integer
Dim a4 As Integer
Dim a5 As Integer
Dim a6 As Integer
Dim a7 As Integer
Dim a8 As Integer
Dim a9 As Integer
Dim a10 As Integer
Dim a11 As Integer
Dim a12 As Integer
Private Sub Cmd_step_Click()
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
Text5.Enabled = False
Me.Text_TLE.Enabled = False
List1.AddItem "第一轮开始"
a1 = Val(Text1.Text) + Val(Text2.Text)
List1.AddItem Text1.Text & "+" & Text2.Text & "=" & a1
a2 = a1 + Val(Text3.Text)
If a1 + Val(Text3.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a1 & "+" & Text3.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a1 & "+" & Text3.Text & "=" & a2
MsgBox "不满足要求,继续下组数据"
End If
a3 = a1 + Val(Text4.Text)
If a1 + Val(Text4.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a1 & "+" & Text4.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a1 & "+" & Text4.Text & "=" & a3
MsgBox "不满足要求,继续下组数据"
End If
a4 = a1 + Val(Text5.Text)
If a1 + Val(Text5.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a1 & "+" & Text5.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a1 & "+" & Text5.Text & "=" & a4
MsgBox "此组数据均不满足要求,继续下一轮数据"
End If
List1.AddItem "第二轮开始"
a5 = Val(Text1.Text) + Val(Text3.Text)
List1.AddItem Text1.Text & "+" & Text3.Text & "=" & a5
a6 = a5 + Val(Text4.Text)
If a5 + Val(Text4.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a5 & "+" & Text4.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a5 & "+" & Text4.Text & "=" & a6
MsgBox "不满足要求,继续下组数据"
End If
a7 = a5 + Val(Text5.Text)
If a5 + Val(Text5.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a5 & "+" & Text5.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a5 & "+" & Text5.Text & "=" & a7
MsgBox "此组数据均不满足要求,继续下一轮数据"
End If
List1.AddItem "第三轮开始"
a8 = Val(Text2.Text) + Val(Text3.Text)
List1.AddItem Text2.Text & "+" & Text3.Text & "=" & a8
a9 = a8 + Val(Text4.Text)
If a8 + Val(Text4.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a8 & "+" & Text4.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a8 & "+" & Text4.Text & "=" & a9
MsgBox "不满足要求,继续下组数据"
End If
a10 = a8 + Val(Text5.Text)
If a8 + Val(Text5.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a8 & "+" & Text5.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a8 & "+" & Text5.Text & "=" & a10
MsgBox "此组数据均不满足要求,继续下一轮数据"
End If
List1.AddItem "第四轮开始"
a11 = Val(Text3.Text) + Val(Text4.Text)
List1.AddItem Text3.Text & "+" & Text4.Text & "=" & a11
a12 = a11 + Val(Text5.Text)
If a11 + Val(Text5.Text) = Val(Me.Text_TLE.Text) Then
List1.AddItem a11 & "+" & Text5.Text & "=" & Text_TLE.Text
MsgBox "满足要求,演示结束"
Else
List1.AddItem a11 & "+" & Text5.Text & "=" & a12
MsgBox "所有数据均不符合要求,请重新输入"
End If
Text1.Enabled = True
Text2.Enabled = True
Text3.Enabled = True
Text4.Enabled = True
Text5.Enabled = True
Me.Text_TLE.Enabled = True
End Sub
Private Sub Command3_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -