VB Subroutine Procedure Event Procedure General Function Procedure
第八章 过程 VB 中过程分为三种: 子过程: 通用子过程(Subroutine Procedure) 事件过程 (Event Procedure) 函数过程: 通用函数过程(General Function Procedure) 标准函数过程(Standard Function Procedure) 属性过程: Property Procedure 上一页 返回章首 下一页
第八章 过程 8. 2. 2 函数过程的调用 函数调用必须出现在表达式中. 如: Area = trape. Area(3, 6, 4) Print my. Abs(-7) Select Case my. Abs(a) If trape. Area (3, 6, 4) >20 then Print trape. Area(5, 10, my. Abs(-7)) 上一页 返回章首 下一页
第八章 过程 Private Sub my. Sub (a As Integer, b As Integer, c As Integer) a = 2 * a: b = 3 * b: c = 4 * c Print “被调过程:“,a, b , c End Sub ------------Private Sub Form_Click() Dim x As Integer, y As Integer X = 2: y = 6 Print “主调过程:“ , x, y Call my. Sub (x+y, y+1, x) Print “主调过程:“ , x, y End Sub 上一页 返回章首 下一页
第八章 过程 Public Function fac(n As Integer) As Long If n = 1 Then fac = 1 Sub Form_Click() Else Print “fac(4)=”;fac(4) fac = n * fac(n - 1) End Sub End If End Function 上一页 返回章首 下一页
第八章 过程 1. 阅读程序 Public function my. Mul(num as integer) As Integer num = num * 3 Mynul = num End Function 若整形变量var 1的初始值是 3,则执行var 1= my. Mu 1(var 1) 语句后,var 1的值是: A. 3 B. 6 上一页 返回章首 C. 9 下一页 D. 27
第八章 过程 3. 如果希望从过程中返回两种数据信息,可在过程定 义时采用—— A. Sub my. Sub(a as integer) B. B. Sub my. Sub(a as integer, Byval b as integer) C. C. Function myfun (a as integer) D. D. Function myfun(By. Val a as integer, _ E. By. Val b as integer) 上一页 返回章首 下一页
- Slides: 32