我有这个代码和问题,功能 nulovac 中使用的 PoleCisel2 不适用于 PoleCisel ,因此在 PoleCisel中不是函数中的任何项目。
选项明确开启
Module Module1
Function nulovac(PoleCisel() As Integer) As Integer()
Dim i As Integer, UpravenePole() As Integer
ReDim PoleCisel(0 To 9), UpravenePole(0 To 9)
Dim vypis As String
For i = 0 To 9
If PoleCisel(i) < 0 Then
UpravenePole(i) = 0
Else
UpravenePole(i) = PoleCisel(i)
End If
Next i
nulovac = UpravenePole
End Function
Sub Main()
Dim UpravenePole2(9) As Integer, PoleCisel2() As Integer, vypis As String, vypis2 As String, i As Integer
ReDim PoleCisel2(9)
vypis = ""
vypis2 = ""
For i = 0 To 9
PoleCisel2(i) = Int((Rnd() - 0.5) * 200)
Next i
UpravenePole2 = nulovac(PoleCisel2)
For i = 0 To 9
vypis = vypis + Str(PoleCisel2(i)) + ", "
vypis2 = vypis2 + Str(UpravenePole2(i)) + ", "
Next i
MsgBox(vypis + Chr(10) + Chr(10) + vypis2)
End Sub
答案 0 :(得分:0)
我已经解决了,在函数中一定不能是ReDim。