二级计算机VB考试常用代码看完必过.docx

上传人:b****6 文档编号:4771615 上传时间:2022-12-08 格式:DOCX 页数:35 大小:21.75KB
下载 相关 举报
二级计算机VB考试常用代码看完必过.docx_第1页
第1页 / 共35页
二级计算机VB考试常用代码看完必过.docx_第2页
第2页 / 共35页
二级计算机VB考试常用代码看完必过.docx_第3页
第3页 / 共35页
二级计算机VB考试常用代码看完必过.docx_第4页
第4页 / 共35页
二级计算机VB考试常用代码看完必过.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

二级计算机VB考试常用代码看完必过.docx

《二级计算机VB考试常用代码看完必过.docx》由会员分享,可在线阅读,更多相关《二级计算机VB考试常用代码看完必过.docx(35页珍藏版)》请在冰豆网上搜索。

二级计算机VB考试常用代码看完必过.docx

二级计算机VB考试常用代码看完必过

二级计算机VB考试代码

第一套

1

PrivateSubCommand1_Click()DimsumAsLong

n=Val(Text1.Text)sum=0IfnMod2=0Then

'm=?

Else

'm=?

EndIf

'Fori=1TomStep?

'sum=sum+?

NextLabel2.Caption=sumEndSub

PrivateFunctionf(ByValxAsInteger)AsLongy=1

'Fori=1To?

y=y*iNextf=yEndFunction

2

OptionBase1

PrivateSubCommand1_Click()

Dimdays%,month%,year%,day1_1%,n%

Staticmonth_daysAsVariant

month_days=Array(31,28,31,30,31,30,31,31,30,31,30,31)

Fork=0To6

IfOption1(k).Value=TrueThen

day1_1=k

EndIf

Nextkdays=0month=Text2year=Text1

'month_days

(2)=IIf(leap_year(year),29,?

'==计算到要显示月历的月份之前共有多少天==

'Fork=?

Tomonth-1

days=days+month_days(k)Nextk

'====计算要显示月历的月份的第1天是星期几=====

n=(daysMod7+day1_1)Mod7

'================输出月历==================

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

PrivateSubCommand1_Click()

n=1putdatanEndSub

PrivateSubCommand2_Click()n=n+1putdatanEndSub

PrivateSubCommand3_Click()

'n=?

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?

EndSub

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

第二套

1

PrivateSubForm_Load()

Command1.Caption="开始"Command2.Caption="停止"

Timer1.Interval=100Timer1.Enabled=False

EndSub

PrivateSubCommand1_Click()

'Command1.Caption=?

Timer1.Enabled=True

'Command1.Enabled=?

Command2.Enabled=True

EndSub

PrivateSubCommand2_Click()

Timer1.Enabled=FalseCommand2.Enabled=False

'Command1.Enabled=?

EndSub

PrivateSubTimer1_Timer()

IfHScroll1.Value

'HScroll1.Value=?

Else

'HScroll1.Value=?

EndIf

EndSub

2

PrivateSubCommand1_Click()

'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

EndIf

IfMid(st1,n,1)=""Then

st2=st2&UCase(Mid(st1,n+1,1))

n=n+1

EndIf

Loop

'Text2.Text=?

EndSub

3

Functionprime(ByValnAsInteger)AsBoolean

'******考生编写******

'************************

EndFunction

 

PrivateSubForm_Click()

'******考生编写******

'************************

OpenApp.Path&"\out5.txt"ForOutputAs#1

Print#1,Text1.Text

Close1

EndSub

第三套

1

PrivateSubDir1_Change()

'File1.Path=?

EndSub

PrivateSubDrive1_Change()

'Dir1.Path=?

EndSub

PrivateSubFile1_Click()

Label2.Caption=File1.FileName

EndSub

PrivateSubOption1_Click(IndexAsInteger)

'If?

=0Then

Drive1.Drive="c:

\"

File1.Pattern="*.*"

Else

'File1.Pattern=?

EndIf

EndSub

2

Dima(5,5)AsString

PrivateSubCommand1_Click()

DimsAsString

Randomize

Fori=1To5

Forj=1To5

a(i,j)=Chr(Rnd*(90-65)+65)

's=s+?

+""

Next

s=s&Chr(13)&Chr(10)

Next

'Text1=?

EndSub

PrivateSubCommand2_Click()

MaxI=1

MaxJ=1

Max=Asc(a(1,1))

Fori=1To5

Forj=1To5

'If?

>MaxThen

Max=Asc(a(i,j))

MaxI=i

MaxJ=j

EndIf

Next

Next

'Text2=Chr(?

)&Str(MaxI)&Str(MaxJ)

EndSub

3

Dima(5,5)AsLong

Dimb(5,5)AsLong

PrivateSubCommand1_Click()

'OpenApp.Path&"\in5.txt"For?

As#1

Fori=1To5

Forj=1To5

'Input#1,?

s=s+Str(a(i,j))

Next

s=s+Chr(13)+Chr(10)

Next

Text1=s

'?

EndSub

PrivateSubCommand2_Click()

'===============以下由考生编写=================

'===========考生编写程序结束======================

EndSub

PrivateSubCommand3_Click()

'=======以下由考生编写===========================

'============考生编写程序结束=========================

OpenApp.Path&"\out5.txt"ForOutputAs#1

Print#1,Label2.Caption

Close#1

EndSub

第四套

1

PrivateSubCommand1_Click()

Randomize

Text2.Locked=False

Text1="":

Text2="":

text3=""

Fori=1To20

s=Chr$(Int(Rnd*26)+97)

'Text1=Text1+?

Next

EndSub

PrivateSubText2_KeyPress(KeyAsciiAsInteger)

DimmAsInteger,nAsInteger

IfLen(Text2)=20Then

'Text2.Locked=?

m=0:

n=0

Fori=1To20

'IfMid(Text2,i,1)=?

Then

'm=?

Else

'n=?

EndIf

Next

text3=m/(m+n)*100&"%"

EndIf

EndSub

PrivateSubCommand2_Click()

End

EndSub

2

OptionBase1

Dimstu(1To50)AsStudType

Dimn%

PrivateSubCmd1_Click(IndexAsInteger)

'SelectCase?

Case0

Ifn<50Then

'n=?

stu(n).Num=Text1

stu(n).Name=Text2

stu(n).Total=Text3

Text1="":

Text2="":

Text3=""

Label4.Caption="已输入"&Space

(1)&n&Space

(1)&"人"

Else

MsgBox"输入人数已超过50!

"

EndIf

Case1

'Max=?

maxi=1

Forj=2Ton

'Ifstu(j).Total>?

Then

Max=stu(j).Total

'maxi=?

EndIf

Next

Text1=stu(maxi).Num

Text2=stu(maxi).Name

Text3=stu(maxi).Total

Label4.Caption="位置:

"&Space

(2)&maxi&"/"&n

Case2

End

EndSelect

EndSub

OptionBase1

Dima(20,6)AsInteger

PrivateSubCommand1_Click()

OpenApp.Path&"\in5.dat"ForInputAs#1

Fori=1To20

Forj=1To6

Input#1,a(i,j)

Text1=Text1+Str(a(i,j))+Space

(1)

Nextj

Text1=Text1+Chr(13)+Chr(10)

Nexti

Close#1

EndSub

PrivateSubCommand2_Click()

'============以下由考生编写===========================

'==========考生编写程序结束=========================

EndSub

PrivateSubForm_Unload(CancelAsInteger)

OpenApp.Path&"\out5.dat"ForOutputAs#1

Print#1,Text2.Text

Close#1

EndSub

第五套

1

PrivateSubCommand1_Click()

Randomize

'Fork=?

To9

'?

=Int(Rnd*90+10)

Nextk

EndSub

PrivateSubCommand2_Click()

'Fork=0To?

temp=Label1(k).Caption

Label1(k).Caption=Label1(9-k).Caption

'?

=temp

Nextk

EndSub

2

Dimr%,x0%,y0,a

PrivateSubCommand1_Click()

Timer1.Enabled=True

EndSub

PrivateSubForm_Load()

r=Shape1.Width/2

'x0=?

+r

y0=Shape1.Top+r

'Image1.Left=x0-?

Image1.Top=y0-r-Image1.Height/2

a=90

EndSub

PrivateSubTimer1_Timer()

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

EndSub

3

PrivateSubCommand1_Click()

Open"in5.dat"ForInputAs#1

n=LOF

(1)

'ch$=Input(n,?

Close#1

Text1.Text=ch

EndSub

PrivateSubCommand2_Click()

DimIsSpaceAsBoolean

ch1$=Text1.Text

'n=Len(?

IsSpace=True

Fork=1Ton

'c=Mid(ch1,k,?

Ifc=""Then'双引号中是一个空格符

IsSpace=True

Else

IfIsSpaceThen

c=UCase(c)

IsSpace=False

EndIf

EndIf

'ch2$=ch2$&?

Nextk

Text1.Text=ch2

EndSub

PrivateSubCommand3_Click()

Open"out5.dat"ForOutputAs#1

Print#1,Text1.Text

Close#1

EndSub

第六套

1

PrivateSubCommand1_Click()

str1=Text1.Text

str2=Text2.Text

'n=Len(?

'Fori=1ToLen(?

IfMid(str1,i,n)=RTrim(str2)Then

'MsgBoxstr2&"的起始位置是:

"&?

ExitFor

EndIf

Next

'Ifi>?

ThenMsgBox"没有找到!

"

EndSub

PrivateSubForm_Load()

Text1.Text="LastweekIwenttothetheatre.Ihadagoodseat.Theplayisveryinteresting.Ididnotenjoyit.Ayoungmanandayoungwomanwereseatingbehindme.Theyweretalkingloudly."

EndSub

2

PrivateSubshowPic_Click()

Picture1.Visible=True

Text1.Visible=False

'If?

="显示图片"Then

Picture1.Picture=LoadPicture(App.Path&"\pic4.bmp")

showPic.Caption="清空图片"

Else

'Picture1.Picture=?

showPic.Caption="显示图片"

EndIf

EndSub

PrivateSubshowText_Click()

'Picture1.Visible=?

Text1.Visible=True

'OpenApp.Path&"\data4.dat"?

As#1

Input#1,s

'Text1.Text=?

Close#1

EndSub

3

PrivateSubCommand1_Click()

OpenApp.Path&"\data5.dat"ForInputAs#1

Input#1,x

'Label1.Caption=?

'Close?

EndSub

PrivateSubCommand2_Click()

'=========以下考生编写===============================

'=======考生编写程序结束============================

OpenApp.Path&"\out5.dat"ForOutputAs#1

Print#1,Label2.Caption

Close#1

EndSub

PrivateFunctionp(nAsInteger)AsBoolean

flag=True

Fori=2ToSqr(n)

IfnModi=0Then

flag=False

ExitFor

EndIf

Nexti

p=flag

EndFunction

第七套

1

PrivateSubCommand1_Click()

Fori=0To6

'k=?

'Forj=i+1To?

'IfVal(Text1(j).Text)>?

Then

k=j

EndIf

Nextj

j=Text1(i).Text

Text1(i).Text=Text1(k).Text

'Text1(k).Text=?

Nexti

EndSub

2

PrivateSubCommand1_Click()

Fork=0ToCombo1.ListCount-1

'IfCombo1.Text=?

Then

ExitFor

EndIf

Nextk

Ifk>=Combo1.ListCountThen

'Combo1.AddItem?

Else

MsgBox("此项目已存在!

")

EndIf

EndSub

PrivateSubCommand2_Click()

IfCombo1.ListIndex>=0Then

'Comb

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 外语学习 > 法语学习

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1