vb 求最大值函数 结果用megbox函数输出
答案:3 悬赏:50 手机版
解决时间 2021-04-06 18:15
- 提问者网友:送舟行
- 2021-04-06 07:43
rt
最佳答案
- 五星知识达人网友:西风乍起
- 2020-11-08 04:35
Private Sub Command1_Click()
MsgBox Max(1, 4, 3, 7, 6, 3, 6)
MsgBox Max(4, 9)
End Sub
Public Function Max(ParamArray a() As Variant) As Variant
If Not IsMissing(a) Then
Dim item
item = a(0)
Dim i As Integer
For i = 1 To UBound(a)
If item < a(i) Then item = a(i)
Next
Max = item
End If
End Function
MsgBox Max(1, 4, 3, 7, 6, 3, 6)
MsgBox Max(4, 9)
End Sub
Public Function Max(ParamArray a() As Variant) As Variant
If Not IsMissing(a) Then
Dim item
item = a(0)
Dim i As Integer
For i = 1 To UBound(a)
If item < a(i) Then item = a(i)
Next
Max = item
End If
End Function
全部回答
- 1楼网友:山河有幸埋战骨
- 2020-04-28 19:50
private sub cmd显示_click()
list2.clear
for i = 0 to list1.listcount - 1
if list1.selected(i) then list2.additem list1.list(i)
next
end sub
private sub cmd清除_click()
list2.clear
end sub
如果添加到list2后删除list1中的选项:
private sub cmd显示_click()
list2.clear
for i = list1.listcount - 1 to 0 step -1
if list1.selected(i) then
list2.additem list1.list(i), 0
list1.removeitem i
end if
next
end sub
- 2楼网友:三千妖杀
- 2019-11-26 05:36
Private Function Max(Arr As Variant)
Max = Arr(0)
For i = 0 To UBound(Arr)
If Arr(i) > Max Then Max = Arr(i)
Next
End Function
Private Sub Command1_Click()
Arr = Array(9.52, 9.53, 9.34, 9.57, 9.6, 9.8, 9.9)
MsgBox Max(Arr)
End Sub
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯