比较大小:2,20,24,25,[7,16,19]
1、 用变量比较大小
x% = InputBox("请输入第一个数")
For i = 2 To 5
y% = InputBox("请输入下一个数")
If x < y Then
x = y
End If
Next i
Print "最大值" & x
2、 用数组比较大小
Dim a(5) As Integer
For i = 1 To 5
a(i) = InputBox("请输入一个数")
Next i
Max = a(1)
Min = a(1)
For i = 2 To 5
If Max < a(i) Then
Max = a(i)
End If
If Min > a(i) Then
Min = a(i)
End If
Next i
Print "最大值" & Max
Print "最小值" & Min
列表框的添加和删除:
列表的名称.AddItem 内容
列表的名称.RemoveItem 位置序号
listcount 数据总个数
listindex 被选中的数据的位置序号
text 被选中的数据内容
list(属性窗口) 列表框中的所有内容
list(n) (代码窗口) 列表框中第n个位置上的数据内容
list(listindex) (代码窗口) 列表框中选中的内容
Text与list(listindex)的区别::
使所选择的数据变成QQ
List1.Text = "QQ" ' 错误
List1.List(List1.ListIndex) = "QQ" '正确
将所选择的数据内容放在文本框中
Text1.Text = List1.Text '正确
Text1.Text = List1.List(List1.ListIndex) '正确
注意:List1.Text 不可以放在等号的左边作为赋值的对象
List2.AddItem List1.Text 将list1中选中的内容添加到list2中
List2.AddItem List1.List(List1.ListIndex) 将list1中选中的内容添加到list2中
List1.RemoveItem List1.ListIndex 将list1中选中的数据删除
List1.AddItem Text1.Text 将Text1中的内容添加到list1中
for i=0 to listcount-1
……
next i
将list1中与text1相同的内容删除
For i = 0 To List1.ListCount - 1
If List1.List(i) = Text1.Text Then
List1.RemoveItem i
End If
Next i
将list1中选择的内容移到list2中
方法一:(不适用多选)
List2.AddItem List1.Text
List1.RemoveItem List1.ListIndex
方法二:(适用多选)
For i = List1.ListCount - 1 To 0 Step -1
If List1.Selected(i) Then
List2.AddItem List1.List(i)
List1.RemoveItem i
End If
Next i
结论:一部分
题
快递公司问题件快递公司问题件货款处理关于圆的周长面积重点题型关于解方程组的题及答案关于南海问题
,必须用For i = List1.ListCount - 1 To 0 Step -1,不能用For i = 0 To List1.ListCount - 1