为了账号安全,请及时绑定邮箱和手机立即绑定

用VB怎么定义一个函数?

用VB怎么定义一个函数?

慕村9548890 2019-02-14 15:11:46
用VB怎么定义一个函数
查看完整描述

2 回答

?
慕森王

TA贡献1777条经验 获得超3个赞

Dim t As Long
_________________________________________

Public Function j(n As Integer) As Long

t = 1
For i = 1 To n
t = t * i
Next i

j = t

End Function
_______________________________________
Private Sub Command1_Click()
Text1.Text = j(8) '这里就可以调用函数了
End Sub

查看完整回答
反对 回复 2019-03-10
?
森林海

TA贡献2011条经验 获得超2个赞

Private Function f(Dim n As Integer) as Integer
if n=0 then
f=1
else
for i=1 to n
t=t*i
next
f=t
endif
End Function

调用的时候如下,x等于24
x=f(4)



查看完整回答
反对 回复 2019-03-10
  • 2 回答
  • 0 关注
  • 4226 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信