Sub a() Dim r As Single, s! r= Cells(2, 5) s= *r*r Cells(2, 11) =s End Sub Sub b() Dim h%, w%, s% h= Cells(3, 5): w= Cells(3, 6) s=h*w Cells(3, 11) =s End Sub Sub c() Dim y As Integer, M As Integer, D As Integer y= Cells(4, 5): M= Cells(4, 6) Select Case M Case 1, 3, 5, 7, 8, 10, 12 D= 31 Case 4, 6, 9, 11 D= 30 Case 2 Ify Mod 4=0 And y Mod 100 <> 0 Ory Mod 400 =0 Then D= 29 Else D= 28 End If End Select Cells(4, 11) =D End Sub Sub D() Dim x As Integer, y As String x= Cells(5, 5) Ifx> 100 Orx<0 Then y=" 成绩输入有误" ElseIf x >= 90 Then y="优" ElseIf x >= 80 Then y="良" ElseIf x >= 70 Then y="中" ElseIf x >= 60 Then y=" 及格" Else y=" 不及格" End If Cells(5, 11) =y End Sub Sub e() Dim n%, s%, x% x= Cells(6, 5) n= 1:s=1^2 'i: 有第 i项,s前 i 项和 Do While s <= xn=n+1s=s+n^2 Loop Cells(6, 11) =n End Sub Sub f() Dim x%, s%, e% s= Cells(7, 5): e= Cells(7, 6) For x=s Toe Ifx Mod 7=5 And x Mod 5=3 Then Exit For End If Next x Cells(7, 11) =x End Sub Sub g() Dim x(1 To 5) As Integer, i%, t%, j% For i=1 To5 x(i) = Cells(8, i+ 4) Next i For i=1 To4 For j=i+1 To5 If x(i) < x(j) Then t= x(i): x(i) = x(j): x(j) =t End If Next j Next i For i=1 To5 Cells(8, 10+ i)= x(i) Next i End Sub S ub h() Dim x(1 To 30) As Long, i%, n% x(1) = 1: x(2) =1 For i=3 To 30 x(i) = x(i - 1)+ x(i - 2) Next in= Cells(9, 5) Cells(9, 11) = x(n) End Sub Sub i() Dim n%, i%, s! n= Cells(10, 5) s=1 For i=1 Tons=s*i Next i Cells(10, 11) =s End Sub Sub j() Dim t As Integer, x%, y% x= Cells(11, 5): y= Cells(11, 6) t= x:x= y:y=t Cells(11, 11) = x: Cells(11, 12) =y End Sub 1. VBA 是嵌入在应用程序中的 Visual Basic 语言。 A VB 最大的不同在于, VBA 必须嵌入在 OFFICE 文档中运行。 A 3. Inputbox 函数的提示信息参数不能缺省。 A 4. Msgbox 函数用来接受用户输入数据。 B ,可以用 语句。 A 6. Office 文档中的宏是 VBA 程序。 A ,应该将该控件 Enabled 属性设置为 False 。B 8. Long 和 Integer 都是整数类型,但是 long 的取值范围更大一些。 A a=8,b=10 ,则表达式(a>b)or(b>0) 的值为真。 A 10. 设 a=8,b=10 ,则表达式 a<=b and not(b>0) 的值为真。 B 11. 如果将布尔常量 False 赋值给一个整型变量,则整型变量的值为-1。B 12. 在逻辑运算符 Not 、 Or 、 And 中,运算优先级有高到低为 Not 、 Or和
Sub a豪华版 来自淘豆网m.daumloan.com转载请标明出处.