在text1(0).text....text1(34)分别对应35个数字 分别是1-35,text1(0).text对应1.text1(34).text对应35,注意是对应不是赋值,程序开始的时候会对text1(0).text到text1(34).text分别进行赋值,还有在text2和text3输入两个值组成一个区间,然后要把text1(0).text....text1(34).text中的任意7个相加得到的和值看在不在text2到text3这个区间内,如果在就把任意7个text1所对以的数字显示在text5里(注意是对应的数字,不是控件组的值)。要把里面每组都找出来,可以组成多少就显示多少 中间要用&隔开。如果没有就提示没有符合要求的数据。我不知道怎么去实现 请高手指点。谢谢。
for i2= i1+1 to 34
for i3= i2+1 to 34
for i4= i3+1 to 34
for i5= i4+1 to 34
for i6= i5+1 to 34
for i7= i6+1 to 34
sum=text1(i1).text+.....+text1(i7).text
if sum>=text2.text and sum <=text3.text
text5.text= text5.text & vbcrlf & text1(i1).text & "&" & text1(i2).text ...next
next
next
next
next
next
next
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) http://feiyun0112.cnblogs.com/
for i2= 0 to 34
for i3= 0 to 34
for i4= 0 to 34
for i5= 0 to 34
for i6= 0 to 34
for i7= 0 to 34
if Not (i1=i2 Or i1=i3 Or i1=i4 Or ...... i6=i7) Then
sum=text1(i1).text+.....+text1(i7).text
if sum>=text2.text and sum <=text3.text Then
text5.text= text5.text & vbcrlf & text1(i1).text & "&" & text1(i2).text ...
End If
End If
next
next
next
next
next
next
next
for i2= 1 to 34
for i3= 2 to 34
for i4= 3 to 34
for i5= 4 to 34
for i6= 5 to 34
for i7= 6 to 34
if Not (i1=i2 Or i1=i3 Or i1=i4 Or ...... i6=i7) Then
sum=text1(i1).text+.....+text1(i7).text
if sum>=text2.text and sum <=text3.text Then
text5.text= text5.text & vbcrlf & text1(i1).text & "&" & text1(i2).text ...
End If
End If
next
next
next
next
next
next
next
for i2= 0 to 34
for i3= 0 to 34
for i4= 0 to 34
for i5= 0 to 34
for i6= 0 to 34
for i7= 0 to 34
if Not (i1=i2 Or i1=i3 Or i1=i4 Or i1=i5 Or i1=i6 Or i1=i7 Or i2=i3 Or i2=i4 Or i2=i5 Or i2=i6 Or i2=i7 Or i3=i4 ....Or i5=i6 Or i5=i7 Or i6=i7) Then
sum=text1(i1).text+.....+text1(i7).text
if sum>=text2.text and sum <=text3.text Then
text5.text= text5.text & vbcrlf & text1(i1).text & "&" & text1(i2).text ... & text1(i7).text
End If
End If
next
next
next
next
next
next
next
在循环中加个DoEvents