大学VB实验教材的实验与习题答案Word下载.docx
《大学VB实验教材的实验与习题答案Word下载.docx》由会员分享,可在线阅读,更多相关《大学VB实验教材的实验与习题答案Word下载.docx(86页珍藏版)》请在冰豆网上搜索。
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
第三章实验与习题
实验
实验3_1
‘算术运算
PrivateSubCommand1_Click()
ConstaAsSingle=3,bAsSingle=2,cAsSingle=-1,dAsSingle=6
DimxAsSingle,yAsSingle,zAsSingle,mAsSingle
x=2:
y=1:
z=1:
m=1
List1.Clear
List1.AddItema/(b+c/b)
List1.AddItem(x+Sqr(x^2+1))^(1/3)
List1.AddItem((2*y)/(a*x+b*y)*(a*x-b*y))
List1.AddItem1+1/(1+1/m)
List1.AddItem1/2*(d/3)^(2*x)
List1.AddItemLog(y+Cos(x)^2)
List1.AddItemAbs((Exp(x)+Sin(x)^3)/(x+y))
List1.AddItemLog((Exp(x*y)+Abs(1/Tan(z)+Cos(x)^3))/(x+y-z))
List1.AddItemSin(45*3.1415/180)+(Exp(10)+Log(10))/Sqr(x+y+1)
List1.AddItemLog(a)/Log(b)
EndSub
‘关系运算
PrivateSubCommand2_Click()
List1.AddItemMid("
VisualBasic"
1,12)=Right("
LanguageVisualBasic"
12)
List1.AddItem"
ABCRG"
>
="
abcde"
List1.AddItemInt(134.69)>
=CInt(134.9)
List1.AddItem78.9/32.77<
=97.5/43.87And-45.4>
-4.98
List1.AddItemStr(32.345)=CStr(32.345)
‘逻辑运算
PrivateSubCommand3_Click()
DimxAsInteger,yAsInteger
DimC1AsInteger,C2AsInteger,C3AsInteger
C1=70:
C2=80:
C3=90
x=9:
y=-2
List1.AddItemx+y<
10Andx-y>
0
List1.AddItem(x%>
=0Andy%>
=0)Or(x%<
0Andy%<
0)
List1.AddItemx=0Xory=0
List1.AddItemC1+C2+C3>
=255OrC1>
90AndC2>
90AndC3>
80
实验3_2
略
实验3_3
实验3_4
‘零售结算
DimdjAsSingle,slAsSingle,jeAsSingle,nAsInteger
Label1.Caption="
金额:
"
dj=InputBox("
请输入商品的单价:
"
单价框"
)
sl=InputBox("
请输入商品的数量:
数量框"
1)
je=dj*sl
n=MsgBox("
共计金额="
&
je,vbOKCancel+vbInformation,"
结果"
Ifn=vbOKThenLabel1.Caption="
Str(je)&
"
元"
‘产生随机数
DimmAsInteger,nAsInteger
Dimx1AsInteger,x2AsInteger,x3AsInteger
m=Val(Text1.Text):
n=Text2.Text
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)
‘求逆序数
DimaAsInteger,hAsInteger,tAsInteger,nAsInteger
a=Int(Rnd*(999-100+1)+100)
h=Mid(CStr(a),1,1)
t=Mid(CStr(a),2,1)
n=Right(CStr(a),1)
Label5.Caption=a&
-->
Format(n*100+t*10+h,"
000"
实验3_5
选择题
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
C
81.
82.
83.
84.
85.
86.
87.
88.
89.
填空题
1、2-32768~32767
2、整型长整型单精度双精度
3、0False“”
4、Chr(Int(Rnd*(Asc(“L”)-Asc(“C”))+Asc(“C”)))
x>
0Andy>
0Orx<
0Andy<
c>
=”a”Andc<
=”z”Orc>
=”A”Andc<
=”Z”
=10Andx<
20
x<
zXory<
z
5、False
2
True
False
6、188
200100
68.56
876554
7、a=1b=1
a=2b=1
a=3b=1
a=4b=1
8、YMod4=0AndYMod100<
>
0OrYMod400=0
9、HeSaid,“Goodmorning”.
10、EDEF
11、(A>
0AndA<
Int(A))And(B<
0AndB<
Int(B))
12、a+b+c+d
(a+b+c+d)/4
sum
aver
13、(f-2*h)/2
(4*h-f)/2
简答题
1、略
2、PrivateSubForm_Click()
Constg=9.8
DimV0AsSingle,tAsSingle
DimSAsSingle
V0=InputBox("
请输入V0的值:
t=InputBox("
请输入时间t的值:
S=(1/2)*g*t^2+V0*t
MsgBox("
位移量为:
S)
3、Priv