VB上机考试综合应用题选讲Word格式文档下载.docx
- 文档编号:4771727
- 上传时间:2023-05-04
- 格式:DOCX
- 页数:22
- 大小:1.04MB
VB上机考试综合应用题选讲Word格式文档下载.docx
《VB上机考试综合应用题选讲Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《VB上机考试综合应用题选讲Word格式文档下载.docx(22页珍藏版)》请在冰点文库上搜索。
ForOutputAs#1
Print#1,Text1.Text
Close#1
二、判断口令题,关键是一些循环语句及选择结构的综合应用:
IfText1.Text="
123456"
Then
Text1.Text="
口令正确"
Text1.PasswordChar="
"
Text2.Text=Text2.Text-1
IfText2.Text>
0Then
MsgBox"
第"
&
(3-Text2.Text)&
"
次口令错误,请重新输入"
3次输入错误,请退出"
Text1.Enabled=False
三、图片转换题:
PrivateSubTimer1_Timer()
a=a+1
Ifa>
6Then
a=1
SelectCasea
Case1
P1.Picture=LoadPicture("
黄灯.ico"
)
Case2,3
红灯.ico"
Case4,5,6
绿灯.ico"
IfbThenTimer2.Enabled=b
EndSelect
PrivateSubTimer2_Timer()
If(a<
4)And(P2.Left>
P1.LeftAndP2.Left<
P1.Left+P1.Width)OrP2.Left<
=100Then
Timer2.Enabled=False
P2.MoveP2.Left-10,P2.Top,P2.Width,P2.Height
四、数据计算与行列式综合应用题:
OptionBase1
DimArr1(20)AsInteger
DimArr2(20)AsInteger
DimSumAsInteger
SubReadData1()
OpenApp.Path&
\"
datain1.txt"
ForInputAs#1
Fori=1To20
Input#1,Arr1(i)
Nexti
SubReadData2()
datain2.txt"
Input#1,Arr2(i)
SubWriteData(FilenameAsString,NumAsInteger)
FilenameForOutputAs#1
Print#1,Num
ReadData1
ReadData2
Dimarr3(20)AsInteger
Sum=0
arr3(i)=Arr1(i)\Arr2(i)
Sum=Sum+arr3(i)
Next
PrintSum
PrivateSubC3_Click()
WriteData"
dataout.txt"
Sum
五、倒计数器
PrivateSubC1_Click(IndexAsInteger)
SelectCaseIndex
Timer1.Enabled=False
Case0
Timer1.Enabled=True
Text1.Text=Text1.Text+1
六、文本框的使用
OpenApp.Path&
\out7.txt"
ForOutputAs#2
Print#2,Text1.Text
Close#2
PrivateSubForm_Load()
\in7.txt"
DoWhileNotEOF
(1)
Input#1,mystring
Text1.Text=Text1.Text+mystring
Loop
Close#1
Text1.Text="
计算机等级考试"
+Text1.Text
七、求某类数的和等:
PrivateFunctionfun(aAsInteger)AsInteger
s%=0
Fori%=500To600
IfInt(i%/a)=i%/aThen
s%=s%+i%
fun=s%
IfOp1.ValueThen
Text1=fun(7)
IfOp2.ValueThenText1=fun(3)
PrivateSubForm_Unload(CancelAsInteger)
out7.txt"
Print#1,Op1.Value,Op2.Value,Text1.Text
八、文本框的使用
Text1.Text=mystring
Text1.Text=UCase(Text1.Text)
九、文本框应用第二例:
第一部分:
窗体程序部分:
Dima(100)AsInteger
PrivateSubCmd1_Click()
\in.txt"
Fori=1To100
Input#1,a(i)
Text1.Text=Text1.Text&
a(i)&
Space
(1)
Nexti
PrivateSubCmd2_Click()
s=0
Ifa(i)Mod2<
>
s=s+a(i)
Next
putdatas
第二部分:
模块程序部分:
(如没有标准模块,需要自行添加一个标准模块)
Subputdata(ByValaAsInteger)
DimsFileAsString
sFile="
\out.txt"
sFileForOutputAs#1
Print#1,a;
十、分苹果题:
OptionExplicit
PrivateSubCommand1_Click(IndexAsInteger)
IfIndex=0Then
IfVal(Label3(0).Caption)>
1Then
Command1(0).Enabled=True
Label3(0).Caption=Label3(0).Caption-1
IfVal(Label3(0).Caption)=1Then
Command1(0).Enabled=False
Else
IfVal(Label3
(1).Caption)>
Command1
(1).Enabled=True
Label3
(1).Caption=Label3
(1).Caption-1
IfVal(Label3
(1).Caption)=1Then
Command1
(1).Enabled=False
EndIf
IfVal(Label3(0).Caption)>
Val(Label3
(1).Caption)Then
picSmile(0).Visible=True
picCry(0).Visible=False
picCry
(1).Visible=True
picSmile
(1).Visible=False
IfVal(Label3(0).Caption)<
picCry(0).Visible=True
picSmile(0).Visible=False
picSmile
(1).Visible=True
picCry
(1).Visible=False
PrivateSubCommand2_Click(IndexAsInteger)
Label3(0).Caption=Label3(0).Caption+1
Else:
Label3
(1).Caption=Label3
(1).Caption+1
picSmile(0).Visible=True
picSmile
(1).Visible=True
Command1(0).Enabled=False
Command1
(1).Enabled=False
十一、简单综合题:
PrivateSubCOMEXIT_Click()
End
PrivateSubCOMSTART_Click()
DimgAsSingle,NAsInteger,SAsSingle
myfile1=App.Path&
grade.DAT"
myfile2=App.Path&
average.dat"
Openmyfile1ForInputAs#1
Openmyfile2ForOutputAs#2
Input#1,g
N=N+1
S=S+g
S=S/N
Write#2,S
Close
COMSTART.Caption="
完成"
COMSTART.Enabled=False
十二、文本加密题:
DimstrinfoAsString
Open"
in7.txt"
ForInputAs1
Input#1,strinfo
Text1.Text=strinfo
DimstrchangeAsString
DimiAsInteger
Fori=1ToLen(Text1.Text)
strchange=strchange+Chr(Asc(Mid(Text1.Text,i,1))+2)
Text1.Text=strchange
ForOutputAs1
Print#1,Text1.Text
十三、数组综合应用题:
本程序解答分二部分,一部分在窗体模块:
Dima(1To100)
DimnAsInteger
DimfAsInteger
DimsAsLong
Input#1,n
a(i)=n
Ifa(i)<
=700Thens=s+a(i)
Callputdata("
out.txt"
s)
Text1.Text=s
另一部分在标准模块:
Subputdata(t_FileNameAsString,t_StrAsVariant)
t_FileName
Print#1,t_Str
十四、素数应用又一例:
本程序分两部分,第一部分在窗体模块:
DimtempAsLong
temp=0
IfOpt2.ValueThen
Fori=200To400
Ifisprime(i)Then
temp=temp+i
Fori=100To200
Text1.Text=temp
putdata"
Text1.Text
第二部分在标准模块:
Subputdata(t_FileNameAsString,T_StrAsVariant)
Print#1,T_Str
Functionisprime(t_IAsInteger)AsBoolean
DimJAsInteger
isprime=False
ForJ=2Tot_I/2
Ift_IModJ=0ThenExitFor
NextJ
IfJ>
t_I/2Thenisprime=True
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- VB 上机 考试 综合 应用题