求个VB代码~高分啊

来源:百度知道 编辑:UC知道 时间:2024/06/21 23:21:56
有5个自己定的数(分别写在text1-text2-text3-text4-text5)里选3个数加起来=10或20或30
求这代码撒
如果没有就说明没有~
前3数=text6里
后2数text7
(比如在text1写10 text2写5 text3写5 text4写20 text写10 这些都是自己写出程序后写在text里的)然后点下Command1~
text6=5、5、10
text7=10、20
懂了吗

以下代码是自己编写的,楼主粘到VB6中就可以,把窗体设计好,需要7个TEXT和一个COMMAND控件,希望能帮到你,另外BSLS
Private Sub Command1_Click()
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Or Text5.Text = "" Then '判断为空
MsgBox "请输入随机数" '作出相应
End If
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim m As Integer
Dim str1 As String
Dim a(4) As Integer '定义变量和数组
a(0) = Text1.Text
a(1) = Text2.Text
a(2) = Text3.Text
a(3) = Text4.Text
a(4) = Text5.Text '初始化数组
For i = 0 To 4
For j = i + 1 To 4
For k = j + 1 To 4
If a(i) + a(j) + a(k) = 10 Or a(i) + a(j) + a(k) = 20 Or a(i) + a(j) + a(k) = 30 Then '判断楼主条件
Text6 = str(a(i)) + "," + str(a(j)) + "," + str(a(k))
For m = 0 To 4
If m <> j And m <> k And m <> i Then