具体程序不写了,写个思路:
1、建立2个数组,一个保存不同文本框内容、一个保存不重复的文本框内容【数组可以同样大小】
2、文本框内容赋值到数组1【也可以直接用文本框的数值】
3、做一个排重函数,把不同的数据放到数组2,并返回数组元素个数
4、做一个排序函数,参数可以有需要排序数组、升序/降序、文本排序/数字排序,方便同类调用,也可以只有需要排序数组
[此贴子已经被作者于2018-2-7 19:43编辑过]
Private Sub Command1_Click() Text1.Text = "" K = 0 For I = 0 To 4 If Check1(I).Value <> 0 Then K = K + 1 AA(K) = Check1(I).Caption End If If Check2(I).Value <> 0 Then K = K + 1 AA(K) = Check2(I).Caption End If Next I For I = 0 To 3 If Check3(I).Value <> 0 Then K = K + 1 AA(K) = Check3(I).Caption End If If Check4(I).Value <> 0 Then K = K + 1 AA(K) = Check4(I).Caption End If If Check5(I).Value <> 0 Then K = K + 1 AA(K) = Check5(I).Caption End If Next I Dim SSA As String For I = 1 To K - 1 For J = I + 1 To K If AA(I) > AA(J) Then SSA = AA(I) AA(I) = AA(J) AA(J) = SSA End If Next J Next I For I = 1 To K If I < K Then Text1.Text = Text1.Text & AA(I) & " - " Else Text1.Text = Text1.Text & AA(I) End If Next I End Sub
For I = 0 To 6 If Check1(I).Value <> 0 Then K = K + 1 AA(K) = Check1(I).Caption End If If Check2(I).Value <> 0 Then K = K + 1 AA(K) = Check2(I).Caption End If Next I '修改为 For I = 0 To 6 If Text1(I).Text <> "" Then K = K + 1 AA(K) = Text1(I).Text End If Next I
[此贴子已经被作者于2018-2-16 15:00编辑过]