VB 数组参数怎么传递
答案:2 悬赏:40
解决时间 2021-03-21 14:10
- 提问者网友:你在我眼中是最帅
- 2021-03-20 15:35
VB 数组参数怎么传递
最佳答案
- 二级知识专家网友:情窦初殇
- 2021-03-20 17:00
简单的给你说一句吧!
public 数组名()as long是你的定义 这句是对的,但你放错位置了 不是放窗体中,而是新建模块,放模块中.这样全局有效!
你前半句说的是错的,后面也是错的.
public sub define_array() '这里是模块(过程)的头,这句是对的 public 可要可不要.
public an_array() as long '在sub()...end sub中不能使用public来什么变量,直接用dim.
end sub
关于使用过程:call define_array() '过程名后面不能跟括号,除非里面传有参数 直接call define_array 或 define_array
redim an_array(5) '这句是对的 对动态数组分配空间
public 数组名()as long是你的定义 这句是对的,但你放错位置了 不是放窗体中,而是新建模块,放模块中.这样全局有效!
你前半句说的是错的,后面也是错的.
public sub define_array() '这里是模块(过程)的头,这句是对的 public 可要可不要.
public an_array() as long '在sub()...end sub中不能使用public来什么变量,直接用dim.
end sub
关于使用过程:call define_array() '过程名后面不能跟括号,除非里面传有参数 直接call define_array 或 define_array
redim an_array(5) '这句是对的 对动态数组分配空间
全部回答
- 1楼网友:错过的是遗憾
- 2021-03-20 18:40
自过程参数类型未定义,算平均分要除以3,不是除以5,正确的代码:
sub proc(a() as integer, max as integer, min as integer, s as integer) n1 = lbound(a) n2 = ubound(a) max = a(n1) min = a(n1) for i = n1 to n2 if max < a(i) then max = a(i) if min > a(i) then min = a(i) s = s + a(i) next i s = (s - max - min) / 3 end sub
private sub command1_click() dim a(1 to 5) as integer, t as integer, a1%, a2% for i = 1 to 5 a(i) = inputbox("请输入第" & i & "位评委分数") print a(i); next i print call proc(a, a1, a2, t) print t end sub
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯