程序是这样的
在窗体frm1中
dim temp1(43) as intergerprivate sub a()
for i=0 to 43
temp1(i)=1
next i
call b
end sub
public function b() as interger()
b=temp1
end function然后在另一个窗体中
private sub c()
dim temp2() as interger
temp2=frm1.b
end sub现在出现一个问题,就是传递不过来,请问是为什么,错在哪里?应该怎么改?谢谢!
在窗体frm1中
dim temp1(43) as intergerprivate sub a()
for i=0 to 43
temp1(i)=1
next i
call b
end sub
public function b() as interger()
b=temp1
end function然后在另一个窗体中
private sub c()
dim temp2() as interger
temp2=frm1.b
end sub现在出现一个问题,就是传递不过来,请问是为什么,错在哪里?应该怎么改?谢谢!
你要在frm1中扫行a函数后才能附值.
(你要在frm1中扫行a函数后才能附值)这个是什么意思啊?
B函数中
FOR I=0 TO 43
B(I)=TEMP1(I)
NEXTC函数中FOR J=0 TO 43
TEMP2(J)=B(J)
a'执行
End Sub
应该b里面call a 才对,a这个sub从来没有运行过,没有初始化,怎么会有值呢?
改为:在窗体frm1中
dim temp1(43) as intergerprivate sub a()
for i=0 to 43
temp1(i)=1
next i
'call b'去掉了
end sub
public function b() as interger()
b=temp1
call a '舔的
end functionto tmd007(学而时习之,不亦乐乎。姓菜名了字灌之号蹭之。)
可以返回数组的
call a '添的
应该放在b=temp1
前面,我都气糊涂了~
'逻辑错误而已
'修改后的代码:
'/////////////////////////////Dim temp1(43) As IntegerPrivate Sub a()
For i = 0 To 43
temp1(i) = 1
Next i
'Call b '将这句去掉
End Sub
Public Function b() As Integer()
a '在这里显执行a 给temp1数组赋值
b = temp1
End Function
'///////////////////////////////////////////