第四章 函数与过程.ppt

gejinhuan@163.com 第四章 函数与过程 葛锦环 gejinhuan@163.com 温州医学院计算机教研室 自定义函数的引入 Private Sub Form_click() Dim a As Integer, temp As Integer a = InputBox(please input a number) temp = 1 For i = 2 To a temp = temp * i Next i Print temp End Sub 自定义函数的引入 Private Sub Form_click() Dim a As Integer, temp As Long a = InputBox(please input a number) temp = fact(a) Print temp End Sub Private Function fact(k As Integer) As Long Dim i As Byte fact = 1 For i = 2 To k fact = fact * i Next i End Function 实例4-3 显示1~1000之间的素数。 要求编制函数过程,用于判断一个整数是否是素数

文档评论(0)

1亿VIP精品文档

相关文档