发布网友 发布时间:2022-05-23 19:57
共3个回答
热心网友 时间:2023-11-19 10:25
Private Sub Command1_Click()
Dim strArray() As String, intArray() As Integer, strArray1() As String, strConversionArray() As String
Dim x(6), y(6), z(6), intOneDimensionalArray() As Integer
Text1.Text = Trim(Text1.Text)
strArray = Split(Text1.Text, " ")
ReDim strArray1(UBound(strArray) - LBound(strArray), 3), strConversionArray(UBound(strArray) - LBound(strArray), 6)
For i = LBound(strArray) To UBound(strArray)
For j = 1 To 3
strArray1(i, j) = Mid(strArray(i), j, 1)
Next j
Next i
ReDim strConversionArray(UBound(strArray) - LBound(strArray), 6)
For i = 1 To 6
x(i) = (i + 1) \ 2
Next i
y(1) = 2: y(2) = 3: y(3) = 1: y(4) = 3: y(5) = 1: y(6) = 2
z(1) = 3: z(2) = 2: z(3) = 3: z(4) = 1: z(5) = 2: z(6) = 1
For i = LBound(strArray) To UBound(strArray)
For j = 1 To 6
strConversionArray(i, j) = strArray1(i, x(j)) + strArray1(i, y(j)) + strArray1(i, z(j))
Next j
Next i
ReDim intArray(UBound(strArray) - LBound(strArray), 6)
For i = LBound(strArray) To UBound(strArray)
For j = 1 To 6
intArray(i, j) = Val(strConversionArray(i, j))
Next j
Next i
ReDim intOneDimensionalArray(((UBound(strArray) - LBound(strArray)) + 1) * 6)
For i = LBound(strArray) To UBound(strArray)
For j = 1 To 6
intOneDimensionalArray(r) = intArray(i, j)
r = r + 1
Next j
Next i
For i = LBound(intOneDimensionalArray) To UBound(intOneDimensionalArray) - 1
For j = i + 1 To UBound(intOneDimensionalArray)
If intOneDimensionalArray(j) < intOneDimensionalArray(i) Then
t = intOneDimensionalArray(i)
intOneDimensionalArray(i) = intOneDimensionalArray(j)
intOneDimensionalArray(j) = t
End If
Next j
Next i
For i = LBound(intOneDimensionalArray) + 1 To UBound(intOneDimensionalArray)
Text2.Text = Text2.Text + CStr(intOneDimensionalArray(i)) + Space(1)
Next i
End Sub
热心网友 时间:2023-11-19 10:26
供参考。朋友热心网友 时间:2023-11-19 10:26
写两个自定义函数