码迷,mamicode.com
首页 > 编程语言 > 详细

VB之数组

时间:2018-03-31 19:36:21      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:ica   http   png   bug   color   command   inpu   gpo   col   

技术分享图片

1.动态数组 一直给每一个数组赋值,直到空的停止,最多a(0.1.2)

2.排序

Dim a(9) As Long
Private Sub Command1_Click()
Dim i As Long, j As Long, b As Long
For i = 1 To 9
For j = 0 To 9 - i
‘Debug.Print i
If a(j) < a(j + 1) Then
b = a(j)
Debug.Print j
a(j) = a(j + 1)
a(j + 1) = b
End If
Next j
Next i
For i = 0 To 9
Text1.Text = Text1.Text + CStr(a(i)) + " "
If i = 4 Then Text1.Text = Text1.Text + Chr(13) + Chr(10)
Next i
End Sub
Private Sub Command2_Click()
Dim i As Long, l
Text1.Text = ""
For i = 0 To 9
n:
l = InputBox("请输入排序的10个数字,这是第" & CStr(i + 1) & "个", "")
If IsNumeric(i) Then
49
a(i) = l
Else
MsgBox "请输入数字", vbOKOnly, "错误"
GoTo n
End If
Next i
End Sub

VB之数组

标签:ica   http   png   bug   color   command   inpu   gpo   col   

原文地址:https://www.cnblogs.com/gyj4208/p/8683409.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!