二级计算机VB考试常用代码看完必过文档格式.docx
- 文档编号:17715425
- 上传时间:2022-12-08
- 格式:DOCX
- 页数:35
- 大小:21.75KB
二级计算机VB考试常用代码看完必过文档格式.docx
《二级计算机VB考试常用代码看完必过文档格式.docx》由会员分享,可在线阅读,更多相关《二级计算机VB考试常用代码看完必过文档格式.docx(35页珍藏版)》请在冰豆网上搜索。
Picture1.Cls
Picture1.Print"
SUNMONTUEWEDTHUFRISAT"
Fork=1Tomonth_days(month)
Picture1.PrintTab(5*n+1);
k;
n=n+1
Ifn=7ThenPicture1.Print
n=?
EndIfNextkEndSub
==============判断闰年==================
PrivateFunctionleap_year(?
AsInteger)AsBoolean
leap_year=(yearMod4=0AndyearMod100<
>
0OryearMod400=0)
EndFunction
PrivateSubOption1_Click(IndexAsInteger)EndSub
3
PrivateTyperec
nameAsString*3MathAsInteger
ChineseAsIntegerEnglishAsIntegerEndType
Dima(20)Asrec,numAsInteger,nAsInteger
PrivateSubreaddata()
OpenApp.Path&
"
\in5.txt"
ForInputAs#1
k=1DoWhileNotEOF
(1)
Input#1,a(k).name,a(k).Math,a(k).Chinese,a(k).English
k=k+1LoopClose#1
num=?
EndSub
n=1putdatanEndSub
PrivateSubCommand2_Click()n=n+1putdatanEndSub
PrivateSubCommand3_Click()
putdatanEndSub
PrivateSubCommand4_Click()
n=numputdatanEndSub
PrivateSubForm_Load()
ReaddataCommand1_ClickEndSub
PrivateSubputdata(?
AsInteger)
Label1.Caption="
第"
&
k&
条记录"
Text1=a(k).nameText2=a(k).MathText3=a(k).Chinese
Text4=a(k).English
Text5=a(k).Math+a(k).Chinese+a(k).English
SetEnabled?
PrivateSubSetEnabled(mAsInteger)
Command1.Enabled=IIf(m=1,False,True)
Command2.Enabled=IIf(m=num,False,True)
Command3.Enabled=IIf(m=1,False,True)
Command4.Enabled=IIf(?
)EndSub
第二套
Command1.Caption="
开始"
Command2.Caption="
停止"
Timer1.Interval=100Timer1.Enabled=False
EndSub
Command1.Caption=?
Timer1.Enabled=True
Command1.Enabled=?
Command2.Enabled=True
PrivateSubCommand2_Click()
Timer1.Enabled=FalseCommand2.Enabled=False
PrivateSubTimer1_Timer()
IfHScroll1.Value<
HScroll1.MaxThen
HScroll1.Value=?
st1=Trim(?
n=1st2=UCase(Left(st1,1))
DoWhilen<
=Len(st1)IfMid(st1,n,1)<
Then
st2=?
Mid(st1,n+1,1)n=n+1
IfMid(st1,n,1)="
st2=st2&
UCase(Mid(st1,n+1,1))
Loop
Text2.Text=?
Functionprime(ByValnAsInteger)AsBoolean
******考生编写******
************************
PrivateSubForm_Click()
\out5.txt"
ForOutputAs#1
Print#1,Text1.Text
Close1
第三套
PrivateSubDir1_Change()
File1.Path=?
PrivateSubDrive1_Change()
Dir1.Path=?
PrivateSubFile1_Click()
Label2.Caption=File1.FileName
PrivateSubOption1_Click(IndexAsInteger)
If?
=0Then
Drive1.Drive="
c:
\"
File1.Pattern="
*.*"
File1.Pattern=?
Dima(5,5)AsString
DimsAsString
Randomize
Fori=1To5
Forj=1To5
a(i,j)=Chr(Rnd*(90-65)+65)
s=s+?
+"
Next
s=s&
Chr(13)&
Chr(10)
Text1=?
MaxI=1
MaxJ=1
Max=Asc(a(1,1))
>
MaxThen
Max=Asc(a(i,j))
MaxI=i
MaxJ=j
Text2=Chr(?
)&
Str(MaxI)&
Str(MaxJ)
Dima(5,5)AsLong
Dimb(5,5)AsLong
For?
As#1
Input#1,?
s=s+Str(a(i,j))
s=s+Chr(13)+Chr(10)
Text1=s
?
===============以下由考生编写=================
===========考生编写程序结束======================
=======以下由考生编写===========================
============考生编写程序结束=========================
Print#1,Label2.Caption
Close#1
第四套
Text2.Locked=False
Text1="
"
:
Text2="
text3="
Fori=1To20
s=Chr$(Int(Rnd*26)+97)
Text1=Text1+?
PrivateSubText2_KeyPress(KeyAsciiAsInteger)
DimmAsInteger,nAsInteger
IfLen(Text2)=20Then
Text2.Locked=?
m=0:
n=0
IfMid(Text2,i,1)=?
text3=m/(m+n)*100&
%"
End
Dimstu(1To50)AsStudType
Dimn%
PrivateSubCmd1_Click(IndexAsInteger)
SelectCase?
Case0
Ifn<
50Then
stu(n).Num=Text1
stu(n).Name=Text2
stu(n).Total=Text3
Text3="
Label4.Caption="
已输入"
Space
(1)&
n&
人"
MsgBox"
输入人数已超过50!
Case1
Max=?
maxi=1
Forj=2Ton
Ifstu(j).Total>
Max=stu(j).Total
maxi=?
Text1=stu(maxi).Num
Text2=stu(maxi).Name
Text3=stu(maxi).Total
位置:
Space
(2)&
maxi&
/"
n
Case2
EndSelect
Dima(20,6)AsInteger
\in5.dat"
Forj=1To6
Input#1,a(i,j)
Text1=Text1+Str(a(i,j))+Space
(1)
Nextj
Text1=Text1+Chr(13)+Chr(10)
Nexti
============以下由考生编写===========================
==========考生编写程序结束=========================
PrivateSubForm_Unload(CancelAsInteger)
\out5.dat"
Print#1,Text2.Text
第五套
To9
=Int(Rnd*90+10)
Nextk
Fork=0To?
temp=Label1(k).Caption
Label1(k).Caption=Label1(9-k).Caption
=temp
Dimr%,x0%,y0,a
r=Shape1.Width/2
x0=?
+r
y0=Shape1.Top+r
Image1.Left=x0-?
Image1.Top=y0-r-Image1.Height/2
a=90
Dimx,y
a=a-3
x=x0+r*Cos(a*3.14159/180)
y=y0-r*Sin(a*3.14159/180)
Image1.Left=?
-Image1.Width/2
Image1.Top=?
-Image1.Height/2
Open"
in5.dat"
n=LOF
(1)
ch$=Input(n,?
Text1.Text=ch
DimIsSpaceAsBoolean
ch1$=Text1.Text
n=Len(?
IsSpace=True
Fork=1Ton
c=Mid(ch1,k,?
Ifc="
Then'
双引号中是一个空格符
IfIsSpaceThen
c=UCase(c)
IsSpace=False
ch2$=ch2$&
Text1.Text=ch2
out5.dat"
第六套
str1=Text1.Text
str2=Text2.Text
n=Len(?
)
Fori=1ToLen(?
IfMid(str1,i,n)=RTrim(str2)Then
MsgBoxstr2&
的起始位置是:
ExitFor
Ifi>
ThenMsgBox"
没有找到!
Text1.Text="
LastweekIwenttothetheatre.Ihadagoodseat.Theplayisveryinteresting.Ididnotenjoyit.Ayoungmanandayoungwomanwereseatingbehindme.Theyweretalkingloudly."
PrivateSubshowPic_Click()
Picture1.Visible=True
Text1.Visible=False
="
显示图片"
Picture1.Picture=LoadPicture(App.Path&
\pic4.bmp"
showPic.Caption="
清空图片"
Picture1.Picture=?
PrivateSubshowText_Click()
Picture1.Visible=?
Text1.Visible=True
\data4.dat"
Input#1,s
Text1.Text=?
\data5.dat"
Input#1,x
Label1.Caption=?
Close?
=========以下考生编写===============================
=======考生编写程序结束============================
PrivateFunctionp(nAsInteger)AsBoolean
flag=True
Fori=2ToSqr(n)
IfnModi=0Then
flag=False
p=flag
第七套
Fori=0To6
k=?
Forj=i+1To?
IfVal(Text1(j).Text)>
k=j
j=Text1(i).Text
Text1(i).Text=Text1(k).Text
Text1(k).Text=?
Fork=0ToCombo1.ListCount-1
IfCombo1.Text=?
Ifk>
=Combo1.ListCountThen
Combo1.AddItem?
MsgBox("
此项目已存在!
IfCombo1.ListIndex>
=0Then
Comb
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 二级 计算机 VB 考试 常用 代码 看完