发布时间 : 星期四 文章2013vb题i1更新完毕开始阅读
Private Sub Command1_Click()
Dim a() As Variant, n As Integer, Key As Integer a = Array(1, 6, 8, 3, 5, 9, 10, 2, 7, 4) n = UBound(a)
Key = InputBox(\请输入要删除的数\For i = 0 To n
If Key = a(i) Then Exit For Next i
If i = n + 1 Then MsgBox (\找不到此数\For j = i + 1 To n a(j - 1) = a(j) Next j n =
- 1
Exit Sub
ReDim Preserve a(n) For i = 0 To n Print a(i); Next i: Print End Sub (4分)
4、* 杨辉三角形如图所示{
Private Sub Form_Click()
Dim a(1 To 10, 1 To 10) As Integer, i%, j% For i = 1 To 10 a(i, 1) = 1 a(i, Next i
For i = 3 To 10 For j = 2 To i - 1
a(i, j) = a(i - 1, j - 1) + a(i - 1, j) Next j Next i
For i = 1 To 10
) = 1
For j = 1 To
Print Tab(5 * (j - 1) + 1); a(i, j); Next j Print Next i End Sub
【附图3】(4分)
5、* 利用判断一个三位数是否为对称数(如:343)的函数过程,求出所有三位对称数之和。 * 程序代码如下:
Private Sub Command1_Click() Dim sum As Long,n As Integer sum=0
For n = 100 To 999
If duicheng(n) then sum=sum+Next n End Sub
Public Function duicheng(ByVal i%) As Boolean a = i Mod 10 c = i \\ 100 If a = c Then duicheng=true Else
duicheng=False End If End (4分)
6、* 用子过程输出Fibonacci(斐波那契)数列(0、1、1、2、3、5、8...)的前20项及前20项的和。 * 程序代码如下:
Private Sub Command1_Click()
Dim s&, a%, b%, c% a = 0: b = 1 = a + b Print a Print b For i = 1 To 18 fib a, b, c print s = s + c Next i Print \(斐波那契)数列的前20项的和为:\End Sub Private Sub fib(a, b, c) c = a + b a = b b = c End Sub (4分) 7、* 控件属性改变,如图{
一、选择题: 1-5: ABCBC 6-10: BCDDD 11-15:AACDB 16-20:BCCBC 21-25:CBABC 26-30:ADBAC 31-35:BCABB 36-40:CBDBA 41-45:CBCAA 46-50:BDCAC 二、填空题: 1:1 a