1、pictureflower.wmf) Command1.Visible = False Command2.Visible = False EndPrivate Sub Form_DblClick() Command1.Visible = True Command2.Visible = True第3章 常用标准控件1.C 2. B 3.C. 4.D 5.B 6.B 7.A 8.C 9.B 10.C11.C 12.A 13.C 14.B 15.D16.D 17.C 18.A 19.D 20.A 21.B 三编程及上机调试:1.Private Sub Check1_Click()If Check1.
2、Value = 1 ThenText1.FontBold = TrueElseText1.FontBold = FalseEnd IfPrivate Sub Check2_Click()If Check2.Value = 1 ThenText1.FontItalic = TrueText1.FontItalic = FalsePrivate Sub Check3_Click()Text1.FontUnderline = TrueText1.FontUnderline = FalsePrivate Sub Command1_Click()Text1.Text = 2. Text2.Text =
3、List1.ListCountList1.AddItem Text1.TextDim i As Integeri = List1.ListIndexList1.RemoveItem iCommand3.Enabled = FalseText1.SetFocusPrivate Sub Form_Load()Private Sub List1_Click()Command3.Enabled = True第4章 VB语言基础1.A 2. D 3.D. 4.A 5.A 6.A 7.C 8.D 9.C 10.B11.A 12.D 13.C 14.A 15.A16.C 17.D 18.A 19.B 20.
4、D 21.C 22.A 23.B 24.C 25.C1Private Sub Form_Load() Dim x As Integer, s As String, d As Integer Randomize x = Int(Rnd * 9000 + 1000) s = Trim(CStr(x) d = Val(Right(s, 1) + Mid(s, 3, 1) + Mid(s, 2, 1) + Left(s, 1) Show Print 产生的数;; x;倒序数 d2Private Sub Form_KeyPress(KeyAscii As Integer)输入字符: Chr(KeyAsc
5、ii), ASCII码为: KeyAscii Cls3Private Sub Form_Click() MsgBox 在这里显示提示 & vbCrLf &提示信息, 2 + 16, 请确认或Private Sub Form_Click()MsgBox + Chr(13) + , vbAbortRetryIgnore _+ vbCritical, 第5章 程序控制结构二单选题1.D 2. C 3.C. 4.D. 5.B 6.C 7.A 8.A 9.D 10.C11.C 12.C 13.B 14.B 四编程及上机调试1. Private Sub Form_Click() Dim x As Inte
6、ger, y As Integer x = InputBox(请输入一个数值 If x 20 Then y = x 2 + 3 * x + 2 ElseIf x = 10 Then y = Sqr(3 * x) - 2 0 Then y = 1 / x + Abs(x) End Ifx= x, y= y(2)Select Case实现: Dim x As Integer, y As Integer x = InputBox( Select Case x Case Is 20 y = x 2 + 3 * x + 2=10 y = Sqr(3 * x) - 2 0 y = 1 / x + Abs(
7、x) End SelectPrint 2.Dim a As Integer, b As Integer, c As Integer For i = 100 To 999 a = i 100 b = (i - a * 100) 10 c = i Mod 10 If a 3 + b 3 + c 3 = i Then Print i; k = k + 1 If k Mod 2 = 0 Then Print Next i3 p = 60: r = 0.014 Do p = p * (1 + r) n = n + 1 Loop Until p = 70 Print n;年后世界人口达到 p;亿4 Dim
8、 s As Single, x As Integer, t As Single, n As Integer x = Val(InputBox(请输入x的值, , 2) s = 1 n = 1 m = 1 m = -m t = m * n / x (n - 1) If Abs(t) Max Then Max = a(i, j) k = i p = j最大的数为第 k &行,第 p &列的数: Max3.Dim a(4, 5) As Integer 在窗体声明段声明数组Dim i As Integer, j As IntegerPrivate Sub cmdmatrix_Click() 生成数组按
9、钮 For i = 1 To 4 For j = 1 To 5 a(i, j) = Int(Rnd * 10) 一位的随机数 Picture1.Print a(i, j); 输出元素 Picture1.PrintPrivate Sub cmdcol_Click() 求列和 Dim colsum As Integer txtcol.Text = For j = 1 To 5 列变量先循环 colsum = 0 colsum = colsum + a(i, j) txtcol.Text = txtcol.Text & Str(colsum)Private Sub cmdrow_Click() 求行
10、和 Dim rowsum As Integer txtrow.Text = For i = 1 To 4 行变量先循环 rowsum = 0 rowsum = rowsum + a(i, j) txtrow.Text = txtrow.Text & CStr(rowsum) & vbCrLfPrivate Sub cmdclear_Click() 清除 Picture1.ClsPrivate Sub cmdexit_Click() 结束4. Option Base 1 Dim a() As Integer, b() As Integer, i As Integer, j As Integer,
11、 x As Integer, y As Integer第一维上界 Do While Not IsNumeric(x) x = Int(InputBox() y = InputBox(第二维上界 y = Int(InputBox( ReDim a(x, y)原数组元素为: For i = 1 To x For j = 1 To y a(i, j) = Int(90 * Rnd) + 10转置后数组元素为: For i = 1 To y For j = 1 To x Print a(j, i);5. Option Base 1Dim a(10, 10) As Integer, i As Integ
12、er, j As IntegerFor i = 1 To 10 For j = 1 To 10 If i = j Or i + j = 11 Then a(i, j) = 0 Else a(i, j) = 16. Option Explicit Dim i As Integer, j As Integer, n As Integer, k As Integer, a(11) As Integer j = 1 For i = 3 To 21 Step 2 a(j) = i Print a(j); j = j + 1 n = InputBox(请输入一个数 If n = a(i) Then For
13、 j = i To 10 a(j) = a(j + 1) For i = 1 To 97. Option Base 1Dim a As Variant, k As Integer, i As Integer, j As IntegerDim b As Variantb = Array(17, 35, 128, 235, 89, 121, 143, 189, 231, 94)a = Array(11.3, 12.3, 12#, 11.8, 12.6, 11.6, 12.8, 11.8, 12.4, 12.1)For i = 1 To 9 对数组a的元素排序 For j = i + 1 To 10
14、 If a(k) a(j) Then k = j If k i Then 数组b的元素随数组a的元素一起变动 a(i) = a(k) a(k) = t t = b(i) b(i) = b(k) b(k) = t按名字的排列顺序为: If Len(b(i) = 2 Then b(i) = 0 b(i) 补上数组b中长度为的编号前的第 i &名的号码为: b(i) &,成绩为: a(i)第7章 过程二、单选题1.C 2. D 3.C 4.D 5. B6.A 7. B 8.B 9.C 10.D11.C 12.D 13.B 14.B 15.C16.A 17.B 18.B 三、填空题152 5124 1
15、1 8 3531 3 51. Private Sub Command1_Click() Dim n As Integer For n = 100 To 1600 Step 500n= n;时的近似值是: pi(n) Next nPrivate Function pi(x As Integer) As Single Dim s As Single, k As Integer, m As Integer s = 0 k = 1 s = s + m / k k = k + 2 Loop While k = x pi = 4 * sEnd Function2. Private Sub Command1
16、_Click() Dim x As Integer, i As Integer x = Val(Text1) If prime(i) And prime(x - i) Then Label2 = Str(x) &是 Str(i) &和 Str(x - i) &两个素数之和 Exit SubPrivate Function prime(x As Integer) As Boolean For i = 2 To Int(Sqr(x) If x Mod i = 0 Then prime = False Exit Function prime = True3. Option Explicit Dim i As Integer a(i) = Int(Rnd * 90) + 10 Text1 = Text1 + Str(a(i) Call sort(a) Text2 = Text2 + Str(a(i)Private Sub sort(a() As Integer) Dim k As Integer, i As Integer, j As Integer, t As Integer k = UBound(a) For i = 1 To k - 1 For j = i + 1 To k If a(i)
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1