vb变量转常量的问题

来源:百度知道 编辑:UC知道 时间:2024/07/04 12:33:57
函数值确定要用到数组ud(),但是ud()是在form下确定的,怎样才能在函数运行时保存ud()的值呢?
Function B(ByVal i As Integer, ByVal p As Integer, ByVal u As Double) As Double
n=textbox1.text
For i = 0 To n
If (p = 0 And u < ud(i + 1) And u >= ud(i)) Then B = 1
next i
end function

不明白你要做什么,我估计你是说UD的上限不能确定要在程序中填写把。
可以用
redim ud(n)
改变树组的上限
如ud包含0-5 六个元素 就
redim ud(5)
你的程序就是
Function B(ByVal i As Integer, ByVal p As Integer, ByVal u As Double) As Double
n=textbox1.text
redim ud(n+1) '因为你的ud(i+1)最大为n+1
For i = 0 To n
If (p = 0 And u < ud(i + 1) And u >= ud(i)) Then B = 1
next i
end function

看来兄弟 你还是没有理解透 啊