永发信息网

在vb 中利用函数在事件过程中计算3!+5!+6!

答案:4  悬赏:0  手机版
解决时间 2021-04-06 02:35
  • 提问者网友:两耳就是菩提
  • 2021-04-05 03:35
在vb 中利用函数在事件过程中计算3!+5!+6!
最佳答案
  • 五星知识达人网友:英雄的欲望
  • 2021-04-05 03:59
public function N(num as integer) as integer
dim i as integer
N=1
for i=1 to num
N=N*i
next
end function

private sub command1_click()
msgbox N(3)+N(5)+N(6)
end sub
全部回答
  • 1楼网友:低音帝王
  • 2021-04-05 06:37
具体代码可联系我,返回该参数的阶乘就行了,函数的参数是整形参数写一个按钮事件 button click事件 再写一个函数
  • 2楼网友:我住北渡口
  • 2021-04-05 05:36
private function getresult(m as integer, n as integer, p as integer) as double dim i as integer dim tempa, tempb, tempc as integer tempa = 0 tempb = 0 tempc = 0 for i = 1 to m tempa = tempa + i next i for i = 1 to n tempb = tempa + i next i for i = 1 to p tempc = tempa + i next i getresult = (tempa + tempb) / tempc end function
  • 3楼网友:鱼忧
  • 2021-04-05 04:50
Option Explicit Private Sub Command1_Click()     Dim Num1 As Integer     Num1 = 3     MsgBox Num1 & "的阶乘为:" & Factorial(Num1) End Sub Function Factorial(ByVal Num As Integer) As Long    '参数按值传递     Dim i As Integer     If Num > 0 Then Factorial = 1         For i = 1 To Num             Factorial = Factorial * i         Next i End Function 上面的代码是计算一个数的阶乘,LZ稍微改下即可 满意请采纳,有问题请追问
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯