vb程序设计实验教程与习题选解 王杰华 郑国平 主编

  • 格式:doc
  • 大小:352.50 KB
  • 文档页数:62
List1.AddItem 1 + 1 / (1 + 1 / m)
List1.AddItem 1 / 2 * (d / 3) ^ (2 * x)
List1.AddItem Log(y + Cos(x) ^ 2)
List1.AddItem Abs((Exp(x) + Sin(x) ^ 3) / (x + y))
x = 2: y = 1: z = 1: m = 1
List1.Clear
List1.AddItem a / (b + c / b)
List1.AddItem (x + Sqr(x ^ 2 + 1)) ^ (1 / 3)
List1.AddItem ((2 * y) / (a * x + b * y) * (a * x - b * y))
Next j
End Sub
习题

1.A
2.C
3.D
4.C
5.B
6.D
7.D
8.B
9.D
10.B
11.B
12.D

1.Variant
2.ReDim A(N)
A(1)
If M < A(I) Then M = A(I)
3.Int(26 * Rnd) + 65
Chr(t)
i + 1 To 10
t = InputBox("请输入时间t的值:")
S = (1 / 2) * g * t ^ 2 + V0 * t
MsgBox ("位移量为:" & S)
End Sub
3、Private Sub Command1_Click()
Dim l As Single, w As Single, h As Single
Dim s As Single
l = Text1.Text
w = Text2.Text
h = Text3.Text
s = (l * w + l * h + w * h) * 2
Label1.Caption = s
End Sub
第四章
实验答案
实验4-1
方法一:x<=5 ; y
方法二:Is<=2;Case Else
Randomize
x1 = Int(Rnd * (n - m + 1) + m)
x2 = Int(Rnd * (n - m + 1) + m)
x3 = Int(Rnd * (n - m + 1) + m)
Label4.Caption = "结果为:" & Str(x1) & Str(x2) & Str(x3)
End Sub
‘产生随机数
Private Sub Command2_Click()
Dim m As Integer, n As Integer
Dim x1 As Integer, x2 As Integer, x3 As Integer
m = Val(Text1.Text): n = Text2.Text
(a+b+c+d)/4
sum
aver
13、(f-2*h)/2
(4*h-f)/2
简答题
1、略
2、Private Sub Form_Click()
Const g = 9.8
Dim V0 As Single, t As Single
Dim S As Single
V0 = InputBox("请输入V0的值:")
End Sub
‘逻辑运算
Private Sub Command3_Click()
Dim x As Integer, y As Integer
Dim C1 As Integer, C2 As Integer, C3 As Integer
C1 = 70: C2 = 80: C3 = 90
x = 9: y = -2
x>0 And y>0 Or x<0 And y<0
c>=”a”And c<=”z”Or c>=”A”And c<=”Z”
x>=10 And x<20
x<z Xor y<z
5、False
2
True
False
True
True
True
True
6、188
200100
68.56
876554
7、a=1 b=1
6. 32 0
7. 4
8. 15 1
9. 1 ; 401 ;104
10. 1 2 3 ;1 3; 1
11. (3)
12. 2 0 24
13. 10 14
14. BAABC CBAABC
15. X Mod P=0 ; X=X+1 ;Find=False
16. abs(t)<10^(-7) ; s+t
17. Mid(n,1,1)=Mid(n,2,1) And Mid(n,3,1)=Mid(n,4,1)
第一章
习题
一、选择题
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
B
A
A
B
D
B
A
A
C
B
C
D
A
D
第二章
习题
一、选择题
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
C
B
C
A
A
B
B
B
C
C
B
B
D
A
B
30.
31.
32.
33.
34.
35.
36.
37.
P = P & ch
ReDim Preserve C(k)
5_11
Private Sub Form_Click()
Dim x As Integer, i As Integer, k As Integer, j As Integer
Dim a() As Integer
x = InputBox("输入正整数x=")
sl = InputBox("请输入商品的数量:", "数量框", 1)
je = dj * sl
n = MsgBox("共计金额=" & je, vbOKCancel + vbInformation, "结果")
If n = vbOK Then Label1.Caption = "金额:" & Str(je) & "元"
实验4-2
Shape1.BackColor=vbRed;
Inter=15;
Inter=Inter-1;
Inter;
实验4-3
b<c
b=a
a=k
实验4-4
方法二:s*n; t/s<10^-5
实验4-5
方法一:m>=10^-4; (-1)^(n+1)*m
实验4-6
x2=x3 ; <10^-6
实验4-7
实验4-8
i = 2
Print x; "的质因子为:";
Do While x >= i
If x Mod i = 0 Then
k = k + 1
ReDim Preserve a(k)
a(k) = i
x = x \ i
Else
i = i + 1
End If
Loop
For j = 1 To UBound(a)
Print a(j);
a=2 b=1
a=3b=1
a=4b=1
8、Y Mod 4=0 And Y Mod 100<>0 Or Y Mod 400 =0
9、He Said,“Good morning”.
10、EDEF
11、(A>0 And A<>Int(A)) And (B<0 And B<>Int(B))
12、a+b+c+d
D
C
A
C
C
B
75.
B
第三章实验与习题
实验
实验3_1
‘算术运算
Private Sub Command1_Click()
Const a As Single = 3, b As Single = 2, c As Single = -1, d As Single = 6
Dim x As Single, y As Single, z As Single, m As Single
row = I
col = j
5_5
1
ReDim Preserve prime(m)
prime(j)
5_6
d Mod 2
5_7
Exit For
a(j + 1) = a(j)
5_8
N – I
A(j) = A(j + 1)
5_9
A(i, 1)