用VB设计一个程序(一定要用VB啊)

来源:百度知道 编辑:UC知道 时间:2024/05/26 20:31:26
1.输入一组数据(用InputBox或Array函数都行),存放在一个数组a( )中,输入的数据全为整数。
2.将输入的数据两两相减的绝对值存放在另一个数组b( )中。例如输入1 3 6 10 15,则两两相减的绝对值就为:2 5 9 14 3 7 12 4 9 5 里面有可能有重复的,但不用管。
3.将b( )中的数据按从小到大的顺序排序,并存放在一个文本框中。
补充一下:a( )中只有6个元素,b( )中只有15个元素

1.
a=array(12,123,1,2,6,3)
for i = 0 to ubound(a)
debug.print a(i)
next

2.
a = array(12,123,1,2,6,3)
ReDim b(UBound(a))
For i = 1 To UBound(a)
b(i) = Abs(a(i) - a(i - 1))
Debug.Print b(i)
Next
3.
Private Sub Command2_Click()

a = Array(12,123,1,2,6,3)
ReDim b(UBound(a))
For i = 1 To UBound(a)
b(i) = Abs(a(i) - a(i - 1))
Debug.Print b(i)
Next

Dim temp As Long
For i = 0 To UBound(b)
For j = i To UBound(b)
If b(i) > b(j) Then
temp = b(i)
b(i) = b(j)
b(j) = temp
End If
Next j
Next i

For i = 0 To UBound(b)
Debug.Print b(i)
Next

End Sub