请教各位,VB中出现子程序或函数未定义,确实不知道怎么办了!
在form1中申明了如下代码:PublicintcountAsInteger'货物数量PublicstrnameAsString'货物名称PublicpriceAsSin...
在form1中申明了如下代码:
Public intcount As Integer '货物数量
Public strname As String '货物名称
Public price As Single '货物单价
Public foresum As Single '折扣前的货物金额
Public sum As Single '折扣后的货物金额
-------------------------------------------------
Public Function fundj(x!) As Single
Dim zk As Single
Select Case x
Case Is >= 500
zk = 0.7 * x
Case Is >= 300
zk = 0.8 * x
Case Is >= 100
zk = 0.9 * x
Case Else
zk = x
End Select
fundj = zk
End Function
然后在form2中需要调用该函数:
Private Sub command2_click() '单击成交按钮
intcount = Val(Text2.Text)
strname = Mid(Combo1.Text, 1, 3)
price = Val(Mid(Combo1.Text, 5, 1))
foresum = intcount * price
sum = fundj(foresum)
End Sub
却始终显示子程序或函数未定义,请教大家,具体是什么原因?
就是到sum = fundj(foresum)的时候就报错了!
光标定义到fundj说子程序或函数未定义! 展开
Public intcount As Integer '货物数量
Public strname As String '货物名称
Public price As Single '货物单价
Public foresum As Single '折扣前的货物金额
Public sum As Single '折扣后的货物金额
-------------------------------------------------
Public Function fundj(x!) As Single
Dim zk As Single
Select Case x
Case Is >= 500
zk = 0.7 * x
Case Is >= 300
zk = 0.8 * x
Case Is >= 100
zk = 0.9 * x
Case Else
zk = x
End Select
fundj = zk
End Function
然后在form2中需要调用该函数:
Private Sub command2_click() '单击成交按钮
intcount = Val(Text2.Text)
strname = Mid(Combo1.Text, 1, 3)
price = Val(Mid(Combo1.Text, 5, 1))
foresum = intcount * price
sum = fundj(foresum)
End Sub
却始终显示子程序或函数未定义,请教大家,具体是什么原因?
就是到sum = fundj(foresum)的时候就报错了!
光标定义到fundj说子程序或函数未定义! 展开
3个回答
2011-12-09
展开全部
为什么不写在同一个form里呢
或者改为
sum = form1.fundj(foresum)
Public foresum As Single '折扣前的货物金额要放form2定义吧?
或者改为
sum = form1.fundj(foresum)
Public foresum As Single '折扣前的货物金额要放form2定义吧?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
把form1中的代码放在模块中
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
调试一下,哪句错了 ?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询