VB试验答案文档格式.docx
《VB试验答案文档格式.docx》由会员分享,可在线阅读,更多相关《VB试验答案文档格式.docx(111页珍藏版)》请在冰豆网上搜索。
PrivateSubCommand1_Click()
Text1.Text=Label1.Caption
PrivateSubCommand2_Click()
End
2-7
PrintTab(5);
"
*"
PrintTab(4);
***"
PrintTab(3);
*****"
PrintTab
(2);
*******"
Cls
PrivateSubCommand3_Click()
Move0,0
2-8
Text1="
千里之行,始于足下"
Text1.Left=Form1.Width-Text1.Width
Command1.Enabled=False
Text1.Visible=True
Text1.Visible=False
Command1.Enabled=True
3-1
DimfAsSingle,cAsSingle
DimanswerAsInteger
'
PrivateSubCmdend_Click()
PrivateSubCmdhs_Click()
f=Val(Txthua.Text)
c=(f-32)*5/9
Txtshe.Text=Str$(c)
PrivateSubCmdsh_Click()
c=Val(Txtshe.Text)
Ifc=0Then
Txthua.Text="
32"
ElseIfc>
0Then
f=(c*9#/5)+32
Txthua.Text=Str$(f)
Else
answer=MsgBox("
非法数据!
vbOKOnly+vbExclamation,"
提示信息"
)
Ifanswer=vbOKThen
Txtshe.Text="
Txtshe.SetFocus
EndIf
3-2
OptionExplicit
DimfsAsInteger
PrivateSubcmdGreat_Click()
Text1.Text=UCase(Text1.Text)
PrivateSubcmdRecall_Click()
Text2.Text=Len(Text1.Text)
PrivateSubcmdSmall_Click()
Text1.Text=LCase(Text1.Text)
3-3
PrivateSubForm_Click()
Dims1AsSingle,s2AsSingle,s3AsSingle
Dimstr1AsString,str2AsString
Dimb1AsBoolean,b2AsBoolean,b3AsBoolean
Dimn1AsInteger,n2AsInteger,n3AsInteger
s1=18\4*4#^2/1.6
s2=25\3Mod3.2*Int(2.5)
str1=UCase("
Xyz"
)&
1234&
LCase("
abC"
b1=3>
4Or5>
4
b2=TrueAndFalse
n1=Int(-3.5)+Fix(3.5)+CInt(2.6)
n2=Len(Str(123)+"
Hello"
s3=Sgn(7Mod3-4)+"
0.75"
b3="
aeoplane"
<
airplane"
n3=Len("
VB程序设计"
Prints1
Prints2
Printstr1
Printb1
Printb2
Printn1
Printn2
Prints3
Print"
******************************"
Printb3
Printn3
3-4
DimxAsInteger,yAsSingle
ConstPI=3.1415926
x=30:
y=x*PI/180
SIN("
;
x;
)="
Sin(y)
cos("
Cos(y)
tan("
Sin(y)/Cos(y)
Print
x=45:
x=90:
3-5
DimmAsInteger,aAsInteger,bAsInteger,cAsInteger,dAsInteger
m=Val(Text1.Text)
a=m\1000
b=m\100-a*10
c=(m\10)Mod10
d=mMod10
Text2.Text=CStr(d*1000+c*100+b*10+a)
End
3-6
DimiAsInteger
Randomize
i=Int(Rnd*(3-1+1))+1
txtInput.FontSize=i*txtInput.FontSize
cmdGreat.Enabled=False
cmdSmall.Enabled=True
txtInput.FontSize=fs
cmdGreat.Enabled=True
txtInput.FontSize=txtInput.FontSize/i
cmdSmall.Enabled=False
fs=txtInput.FontSize
PrivateSubtxtInput_KeyPress(KeyAsciiAsInteger)
IfKeyAscii=13Then
txtInput=UCase(Trim(txtInput))
cmdGreat.SetFocus
4-2
DimstrAsString
str=InputBox("
请输入文本信息"
"
输入"
_
欢迎使用VB6"
Label1.Caption="
DimiAsInteger
i=MsgBox("
你确实要退出吗?
vbYesNo+vbExclamation,"
退出警告"
Ifi=6ThenEnd
4-3
DimgzAsSingle,zgzAsSingle
gz=Val(txtGz)
Ifgz>
=1600Then
zgz=gz*(1+0.1)
ElseIfgz>
=1400Then
zgz=gz*(1+0.15)
zgz=gz*(1+0.2)
txtZGz=CStr(zgz)
txtGz="
txtZGz="
txtGz.SetFocus
4-4
DimtAsInteger,yAsSingle
t=Val(txtTime)
Ift<
10Then
y=30
ElseIft<
50Then
y=30+(t-10)*3
y=30+(t-10)*2.5
Ify<
=150Then
txtCost=CStr(y)
txtCost=CStr(150)
txtTime="
txtCost="
txtTime.SetFocus
4-5
DimcjAsSingle,str1AsString
cj=Val(Text1.Text)
Ifcj>
=90Then
Text2.Text="
A"
ElseIfcj>
=80Then
B"
=70Then
C"
=60Then
D"
=0Then
E"
Text2.Text="
PrivateSubText1_LostFocus()
IfNotIsNumeric(Text1.Text)OrVal(Text1.Text)<
MsgBox"
数据输入错误,重输"
Text1.SetFocus
EndIf
4-6
DimYAsInteger,mAsInteger
DimdAsInteger,w1AsInteger
DimRqAsDate
Dimw2AsString
Rq=Date
Y=Year(Rq)
m=Month(Rq)
d=Day(Rq)
w1=Weekday(Rq)
SelectCasew1
Case1
w2="
日"
Case2
一"
Case3
二"
Case4
三"
Case5
四"
Case6
五"
Case7
六"
EndSelect
Label1.Caption="
今天是"
&
Y&
年"
m&
月"
d&
星期"
w2
4-7
DimY1AsInteger,M1AsInteger
DimflagAsBoolean,D1AsInteger,S1AsString
Y1=Val(txtYear)
M1=Val(txtMonth)
flag=(Y1Mod4=0AndY1Mod100<
>
0)OrY1Mod400=0
SelectCaseM1
Case1,2,3
D1=31:
S1="
一季度"
IfM1=2Then
IfflagThen
D1=29
D1=28
Case4,5,6
D1=30:
二季度"
IfM1=5ThenD1=31
Case7,8,9
三季度"
IfM1=9ThenD1=30
Case10,11,12
四季度"
IfM1=11ThenD1=30
EndSelect
IfflagThen
txtRun="
是闰年"
不是闰年"
txtSea=S1
txtDays=Str(D1)
txtYear="
txtMonth="
txtSea="
txtRun="
txtDays="
4-8
PrivateSubCmdclear_Click()
txta.Text="
Txtb.Text="
Txtc.Text="
Txtx1.Text="
Txtx2.Text="
txta.SetFocus
PrivateSubCmdcup_Click()
a=Val(txta.Text)
b=Val(Txtb.Text)
c=Val(Txtc.Text)
disc=b*b-4*a*c
p=-b/(2*a)
q=Sqr(Abs(disc))/(2*a)
Ifdisc>
Txtx1=Format$(p+q,"
####0.###"
Txtx2=Format$(p-q,"
Txtx1=Str$(p)&
+"
Str$(q)&
i"
Txtx2=Str$(p)&
-"
PrivateSubtxta_KeyPress(KeyAsciiAsInteger)
IfKeyAscii=13Then
IfNotIsNumeric(txta.Text)Then
MsgBox"
数据非法,重输"
Txtb.SetFocus
EndSub
PrivateSubTxtb_KeyPress(KeyAsciiAsInteger)
IfNotIsNumeric(Txtb.Text)Then
Txtc.SetFocus
PrivateSubTxtc_KeyPress(KeyAsciiAsInteger)
IfNotIsNumeric(Txtc.Text)Then
Cmdcup.SetFocus
4-9
txtm1="
txtm2="
txtm3="
Lblinfo.Caption="
txtm1.SetFocus
PrivateSubCmdsort_Click()
Dimm1AsInteger,m2AsInteger,m3AsInteger
m1=Val(txtm1.Text)
m2=Val(txtm2.Text)
m3=Val(txtm3.Text)
If(m1+m2+m3)\3>
95Or(m1=100Andm2=100Andm3>
=80)_
Or(m1=100Andm3=100Andm2>
=80)Or_
(m1>
=80Andm2=100Andm3=100)Then
Lblinfo.Caption="
此学生奖学金为一等奖"
ElseIf(m1+m2+m3)\3>
90Or(m1=100Andm2>
=75Andm3>
=75)_
Or(m1>
=75Andm2=100Andm3>
=75)Or_
=75Andm2>
=75Andm3=100)Then
此学生奖学金为二等奖"
ElseIfm1>
=70Andm2>
=70Andm3>
此学生奖学金为三等奖"
此学生无奖学金"
PrivateSubtxtm1_KeyPress(KeyAsciiAsInteger)
IfNotIsNumeric(txtm1)Then
数据非法,重新输入"
vbExclamation,"
输入操作数1"
txtm1.Text="
txtm1.SetFocus
txtm2.SetFocus
PrivateSubtxtm2_KeyPress(KeyAsc