爱问知识人 爱问教育 医院库

… 10!并用print显示结果?

首页

+…+10!并用print显示结果?

用自定义函数(function),求1!+2!+3!+…+10!并用print显示结果?一定要在VB里求:

用自定义函数(function),求1!+2!+3!+…+10!并用print显示结果?
Private Sub Command1_click()






End Sub
function   fact(x as  integer) as long






end  function

提交回答
好评回答
  • 2019-03-08 23:09:57
    Private Sub Command1_click()
        Dim i As Integer
        Dim Result As Long
        
        For i = 1 To 10
            Result = Result + fact(i)
        Next
        
        Print Result
    End Sub
    Function fact(x As Integer) As Long
        Dim i As Integer
        Dim Result As Long
        
        Result = 1
        
        For i = 1 To x
            Result = Result * i
        Next i
        
        fact = Result
    End Function

    空***

    2019-03-08 23:09:57

其他答案

    2019-03-09 00:01:18
  • 这道题目考得是递归

    爱***

    2019-03-09 00:01:18

  • 2019-03-08 23:43:45
  •   Private Sub Command1_click() 
     Dim PrintData as long
     DIM i as long
       for i= 1 to 10
          PrintData = PrintData + fact(i)
       next i
       print PrintData
    End Sub 
    Function fact(x As Integer) As Long 
      Dim i As Long 
      Dim Result As Long 
        Result = 1 
        For i = 1 To x 
          Result = Result * i 
        Next i 
        fact = Result 
    End Function 
    注意
    1。
       integer 是16位 Long 是32位的,在现在的32位操作系统下,运行的更快 2。用Print 输出结果,是打印在了窗口上面。 要设置窗体的属性,防止刷新。结果看不到!。

    王***

    2019-03-08 23:43:45

类似问题

换一换

相关推荐

正在加载...
最新资料 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 173-192
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):