admin 管理员组

文章数量: 887032


2024年1月23日发(作者:android中createtempfile)

二级计算机VB考试代码

第一套

1

Private Sub Command1_Click() Dim sum As Long

n = Val() sum = 0 If n Mod 2 = 0 Then

' m = ?

Else

' m = ?

End If

' For i = 1 To m Step ?

' sum = sum + ? Next n = sum End Sub

Private Function f(ByVal x As Integer) As Long y = 1

' For i = 1 To ?

y = y * i Next f = y End Function

2

Option Base 1

Private Sub Command1_Click()

Dim days%, month%, year%, day1_1%, n%

Static month_days As Variant

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

For k = 0 To 6

If Option1(k).Value = True Then

day1_1 = k

End If

Next k days = 0 month = Text2 year = Text1

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

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

' For k = ? To month - 1

days = days + month_days(k) Next k

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

n = (days Mod 7 + day1_1) Mod 7

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

" SUN MON TUE WED THU FRI SAT"

For k = 1 To month_days(month)

Tab(5 * n + 1); k; n = n + 1

If n = 7 Then

' n = ?

End If Next k End Sub

'============== 判断闰年 ==================

'Private Function leap_year( ? As Integer) As Boolean

leap_year = (year Mod 4 = 0 And year Mod 100 <> 0 Or year Mod 400 = 0)

End Function

Private Sub Option1_Click(Index As Integer) End Sub

3

Private Type rec

name As String * 3 Math As Integer

Chinese As Integer English As Integer End Type

Dim a(20) As rec, num As Integer, n As Integer

Private Sub readdata()

Open & "" For Input As #1

k = 1 Do While Not EOF(1)

Input #1, a(k).name, a(k).Math, a(k).Chinese, a(k).English

k = k + 1 Loop Close #1

' num = ? End Sub

Private Sub Command1_Click()

n = 1 putdata n End Sub

Private Sub Command2_Click() n = n + 1 putdata n End Sub

Private Sub Command3_Click()

' n = ? putdata n End Sub

Private Sub Command4_Click()

n = num putdata n End Sub

Private Sub Form_Load()

Readdata Command1_Click End Sub

'Private Sub putdata( ? As Integer)

n = "第" & k & "条记录"

Text1 = a(k).name Text2 = a(k).Math Text3 = a(k).Chinese

Text4 = a(k).English

Text5 = a(k).Math + a(k).Chinese + a(k).English

' SetEnabled ? End Sub

Private Sub SetEnabled(m As Integer)

d = IIf(m = 1, False, True)

d = IIf(m = num, False, True)

d = IIf(m = 1, False, True)

' d = IIf( ? ) End Sub

第二套

1

Private Sub Form_Load()

n = "开始" n = "停止"

al = 100 d = False

End Sub

Private Sub Command1_Click()

'n = ? d = True

'd = ? d = True

End Sub

Private Sub Command2_Click()

d = False d = False

'd = ?

End Sub

Private Sub Timer1_Timer()

If < Then

' = ?

Else

' = ?

End If

End Sub

2

Private Sub Command1_Click()

'st1 = Trim( ? )

n = 1 st2 = UCase(Left(st1, 1))

Do While n <= Len(st1) If Mid(st1, n, 1) <> " " Then

'st2 = ? & Mid(st1, n + 1, 1) n = n + 1

End If

If Mid(st1, n, 1) = " " Then

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

n = n + 1

End If

Loop

' = ?

End Sub

3

Function prime(ByVal n As Integer) As Boolean

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

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

End Function

Private Sub Form_Click()

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

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

Open & "" For Output As #1

Print #1,

Close 1

End Sub

第三套

1

Private Sub Dir1_Change()

' = ?

End Sub

Private Sub Drive1_Change()

' = ?

End Sub

Private Sub File1_Click()

n = me

End Sub

Private Sub Option1_Click(Index As Integer)

' If ? = 0 Then

= "c:"

n = "*.*"

Else

' n = ?

End If

End Sub

2

Dim a(5, 5) As String

Private Sub Command1_Click()

Dim s As String

Randomize

For i = 1 To 5

For j = 1 To 5

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

' s = s + ? + " "

Next

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

Next

' Text1 = ?

End Sub

Private Sub Command2_Click()

MaxI = 1

MaxJ = 1

Max = Asc(a(1, 1))

For i = 1 To 5

For j = 1 To 5

' If ? > Max Then

Max = Asc(a(i, j))

MaxI = i

MaxJ = j

End If

Next

Next

' Text2 = Chr( ? ) & Str(MaxI) & Str(MaxJ)

End Sub

3

Dim a(5, 5) As Long

Dim b(5, 5) As Long

Private Sub Command1_Click()

' Open & "" For ? As #1

For i = 1 To 5

For j = 1 To 5

' Input #1, ?

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

Next

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

Next

Text1 = s

' ?

End Sub

Private Sub Command2_Click()

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

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

End Sub

Private Sub Command3_Click()

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

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

Open & "" For Output As #1

Print #1, n

Close #1

End Sub

第四套

1

Private Sub Command1_Click()

Randomize

= False

Text1 = "": Text2 = "": text3 = ""

For i = 1 To 20

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

'Text1 = Text1 + ?

Next

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)

Dim m As Integer, n As Integer

If Len(Text2) = 20 Then

' = ?

m = 0: n = 0

For i = 1 To 20

' If Mid(Text2, i, 1) = ? Then

' m = ?

Else

' n = ?

End If

Next

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

End If

End Sub

Private Sub Command2_Click()

End

End Sub

2

Option Base 1

Dim stu(1 To 50) As StudType

Dim n%

Private Sub Cmd1_Click(Index As Integer)

' Select Case ?

Case 0

If n < 50 Then

' n = ?

stu(n).Num = Text1

stu(n).Name = Text2

stu(n).Total = Text3

Text1 = "": Text2 = "": Text3 = ""

n = "已输入" & Space(1) & n & Space(1) & "人"

Else

MsgBox "输入人数已超过50!"

End If

Case 1

' Max = ?

maxi = 1

For j = 2 To n

' If stu(j).Total > ? Then

Max = stu(j).Total

' maxi = ?

End If

Next

Text1 = stu(maxi).Num

Text2 = stu(maxi).Name

Text3 = stu(maxi).Total

n = "位置:" & Space(2) & maxi & "/" & n

Case 2

End

End Select

End Sub

Option Base 1

Dim a(20, 6) As Integer

Private Sub Command1_Click()

Open & "" For Input As #1

For i = 1 To 20

For j = 1 To 6

Input #1, a(i, j)

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

Next j

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

Next i

Close #1

End Sub

Private Sub Command2_Click()

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

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

End Sub

Private Sub Form_Unload(Cancel As Integer)

Open & "" For Output As #1

Print #1,

Close #1

End Sub

第五套

1

Private Sub Command1_Click()

Randomize

' For k = ? To 9

' ? = Int(Rnd * 90 + 10)

Next k

End Sub

Private Sub Command2_Click()

' For k = 0 To ?

temp = Label1(k).Caption

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

' ? = temp

Next k

End Sub

2

Dim r%, x0%, y0, a

Private Sub Command1_Click()

d = True

End Sub

Private Sub Form_Load()

r = / 2

' x0 = ? + r

y0 = + r

' = x0 - ?

= y0 - r - / 2

a = 90

End Sub

Private Sub Timer1_Timer()

Dim x, y

a = a - 3

x = x0 + r * Cos(a * 3.14159 / 180)

y = y0 - r * Sin(a * 3.14159 / 180)

' = ? - / 2

' = ? - / 2

End Sub

3

Private Sub Command1_Click()

Open "" For Input As #1

n = LOF(1)

' ch$ = Input(n, ? )

Close #1

= ch

End Sub

Private Sub Command2_Click()

Dim IsSpace As Boolean

ch1$ =

' n = Len( ? )

IsSpace = True

For k = 1 To n

' c = Mid(ch1, k, ? )

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

IsSpace = True

Else

If IsSpace Then

c = UCase(c)

IsSpace = False

End If

End If

' ch2$ = ch2$ & ?

Next k

= ch2

End Sub

Private Sub Command3_Click()

Open "" For Output As #1

Print #1,

Close #1

End Sub

第六套

1

Private Sub Command1_Click()

str1 =

str2 =

' n = Len(?)

' For i = 1 To Len(?)

If Mid(str1, i, n) = RTrim(str2) Then

' MsgBox str2 & "的起始位置是:" & ?

Exit For

End If

Next

' If i > ? Then MsgBox "没有找到!"

End Sub

Private Sub Form_Load()

= "Last week I went to the theatre. I had a good seat. The

play is very interesting. I did not enjoy it. A young man and a young woman

were seating behind me. They were talking loudly."

End Sub

2

Private Sub showPic_Click()

e = True

e = False

' If ? = "显示图片" Then

e = LoadPicture( & "")

n = "清空图片"

Else

' e = ?

n = "显示图片"

End If

End Sub

Private Sub showText_Click()

' e = ?

e = True

' Open & "" ? As #1

Input #1, s

' = ?

Close #1

End Sub

3

Private Sub Command1_Click()

Open & "" For Input As #1

Input #1, x

' n = ?

' Close ?

End Sub

Private Sub Command2_Click()

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

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

Open & "" For Output As #1

Print #1, n

Close #1

End Sub

Private Function p(n As Integer) As Boolean

flag = True

For i = 2 To Sqr(n)

If n Mod i = 0 Then

flag = False

Exit For

End If

Next i

p = flag

End Function

第七套

1

Private Sub Command1_Click()

For i = 0 To 6

' k = ?

' For j = i + 1 To ?

' If Val(Text1(j).Text) > ? Then

k = j

End If

Next j

j = Text1(i).Text

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

' Text1(k).Text = ?

Next i

End Sub

2

Private Sub Command1_Click()

For k = 0 To unt - 1

' If = ? Then

Exit For

End If

Next k

If k >= unt Then

' m ?

Else

MsgBox ("此项目已存在!")

End If

End Sub

Private Sub Command2_Click()

If dex >= 0 Then

' Item ?

End If

End Sub

Private Sub Command3_Click()

' = & " " & ?

End Sub

Private Sub Command4_Click()

' ? = ""

End Sub

3

Option Base 1

Dim s As String

Private Sub Command1_Click()

Open & "" For Input As #1

s = Input(LOF(1), #1)

Close #1

= s

End Sub

Private Function GetWords(s As String, words() As String) As Integer

Dim m%, ch$

ch = ""

For k = 1 To Len(s)

c = Mid(s, k, 1)

If c <> " " Then

ch = ch + c

Else

m = m + 1

words(m) = ch

ch = ""

End If

Next k

' GetWords = ?

End Function

Private Sub Command2_Click()

Dim ch(800) As String, n As Integer

If Len(s) = 0 Then

MsgBox "请先使用“读数据”功能!"

Else

' m = GetWords( ? , ch )

'--------------------------考生编写的程序代码从这里开始

'--------------------------考生编写的程序代码到这里结束

End If

End Sub

Private Sub Form_Unload(Cancel As Integer)

Open & "" For Output As #1

Print #1, n

Close #1

End Sub

第八套

Private Sub Command1_Click()

Dim s As Long

Dim i As Integer

i = 0: s = 0

'While i < ?

' ?

s = s + jc(i)

Wend

= s

End Sub

Function jc(n As Integer) As Long

Dim i As Integer

Dim t As Long

' ?

'For i = 1 To ?

t = t * i

Next

' ?

End Function

2

Option Base 1

Private Sub Command1_Click()

Dim arr(50) As Integer

Dim i As Integer, j As Integer

Dim x As Integer, max As Integer, pos As Integer

Randomize

max = 0: pos = 1

i = 1

Do

x = Int(Rnd * 101)

' ?

Do While j < i

If x <> arr(j) Then

' j = j + ?

Else

Exit Do

End If

Loop

If j = i Then

'arr(j) = ?

Print arr(j);

i = i + 1

If (i - 1) Mod 10 = 0 Then Print

If max < x Then

max = x

' pos = ?

End If

End If

Loop Until i > 50

= max

= pos

End Sub

3

Dim a(100) As Integer

Private Sub Command1_Click()

Dim k As Integer

Open & "" For Input As #1

For k = 1 To 100

Input #1, a(k)

Next k

Close #1

End Sub

Private Sub Command2_Click()

Dim i As Integer, j As Integer

Dim b(100) As Integer

j = 0

For i = 1 To 100

If prime(a(i)) Then

j = j + 1

b(j) = a(i)

End If

Next

For i = 1 To j

Text1 = Text1 + Str(b(i))

Next

End Sub

'以下Function 过程用于判断某数是否为质数

Function prime(p As Integer) As Boolean

'考生编写

End Function

Private Sub Form_Unload(Cancel As Integer)

Open & "" For Output As #1

Print #1,

Close #1

End Sub

第九套

Dim n As Integer

Private Sub Form_Click()

' d = ?

End Sub

Private Sub Form_Load()

' al = ?

d = False

lor = 0

n = 0

End Sub

Private Sub Timer1_Timer()

' n = ?

If n Mod 5 = 0 Then

= Time()

End If

If n Mod 8 = 0 Then

' If lor = ? Then

lor = &HFF

Else

lor = 0

End If

End If

End Sub

2

Dim a%(1 To 10)

Private Sub Command1_Click()

Randomize

For k = 1 To 10

a(k) = Int(Rnd * 90 + 10)

a(k);

Next k

"---------------------------------------"

End Sub

Private Sub Command2_Click()

m% = Val(Text1)

' MoveArray a(), ?

For k = 1 To 10

a(k);

Next k

End Sub

Sub MoveArray(a() As Integer, m As Integer)

n% = UBound(a)

' For k = 1 To ?

x = a(1)

For j = 1 To n - 1

' a(j) = a( ? )

Next j

' a(n) = ?

Next k

End Sub

3

Private Type rec

name As String * 3

Math As Integer

Chinese As Integer

English As Integer

End Type

Dim a(30) As rec, num As Integer

Private Sub Command1_Click()

Open & "" For Input As #1

k = 1

' Do While Not EOF( ? )

Input #1, a(k).name, a(k).Math, a(k).Chinese, a(k).English

k = k + 1

Loop

Close #1

' num = ?

End Sub

Private Sub Command2_Click()

'========================考生编写======================

'======================================================

End Sub

Private Sub Command3_Click()

Open & "" For Output As #1

For k = 1 To num

Print #1, a(k).name

Next k

Close #1

End Sub

Private Function sum(k As Integer) As Integer

sum = a(k).Math + a(k).Chinese + a(k).English

End Function

第十套

Private Sub Command1_Click()

' If ? Or dex = unt - 1 Then

dex = 0

Else

If dex >= 0 Then

' dex = ?

End If

End If

ShowInfor

End Sub

Private Sub File1_DblClick()

Call ShowInfor

End Sub

Private Sub ShowInfor()

' n = + "" + ?

e = LoadPicture(n)

End Sub

Private Sub Form_Load()

=

' File1. ?

End Sub

2

Private Sub Command1_Click()

Dim fstr As String, ostr As String

Dim times As Integer, pos As Integer

Dim ans As Integer

fstr = InputBox("输入待查内容", "查找")

If fstr = "" Then

Exit Sub

End If

times = 0

ostr =

pos = InStr(1, ostr, fstr)

Do While pos <> 0

' rt = ?

' gth = ?

' times = ?

= times

ans = MsgBox("找到了,是否继续查找?", vbYesNo)

If ans = vbYes Then

pos = pos + Len(fstr)

' pos = ?

Else

Exit Do

End If

Loop

End Sub

3

Option Explicit

Option Base 1

Dim a(10) As Integer

Private Sub Command1_Click()

Dim i As Integer

Open & "" For Input As #1

For i = 1 To 10

Input #1, a(i)

m (a(i))

Next i

Close #1

End Sub

强化31

Private Sub Command2_Click()

'===================考生编写的程序==============

'===============================================

End Sub

Private Sub Command3_Click()

Dim i As Integer

Open & "" For Output As #1

For i = 0 To 9

Print #1, (i)

Next i

Close #1

End Sub

Private Sub C1_Click()

Dim k As Integer

' Form2. ?

n; 1

n; 2

n; 3

' 1. ? ; ":";

For k = 0 To 1

' If 1( ? ).Value Then

1(k).Caption

End If

Next k

End Sub

Private Sub Form_Load()

' Text2. ? = "*"

End Sub

2

Private Sub C1_Click()

' If ? = "123456" Then

= "口令正确"

' Text1.? = ""

Else

= - 1

' If > ? Then

MsgBox "第" & (3 - ) & "次口令错误,请重新输入"

Else

MsgBox "3次输入错误,请退出"

' d = ?

End If

End If

End Sub

强化32

Private Sub Form_load()

=

' = + - Shape1. ?

=

' = + ? -

= 1000

= 1000

End Sub

Private Sub HScroll1_Change()

' ? =

End Sub

Private Sub VScroll1_Change()

' = ?

End Sub

2

Dim a, t, d

Private Sub Command1_Click()

' Timer1.? = True

d =

End Sub

Private Sub Command2_Click()

Open & "" For Output As #1

Print #1, Label1, Label2

Close #1

End Sub

Private Sub Form_Load()

a = 1

t = 0

End Sub

Private Sub Timer1_Timer()

= - a * 50

If + <= + - 200

Then

' ? = False

' d = ? -

Label1 = d

Label2 = t * al / 1000

End If

a = a + 0.1

' t = ?

End Sub

3

Dim a(30) As Integer, b(30) As Integer, c(60) As Integer

Private Sub Command1_Click()

Dim k As Integer

Open & "" For Input As #1

For k = 1 To 30

Input #1, a(k)

Text1 = Text1 + Str(a(k)) + Space(2)

Next k

For k = 1 To 30

Input #1, b(k)

Text2 = Text2 + Str(b(k)) + Space(2)

Next k

Close #1

End Sub

'考生编写程序

Private Sub Command2_Click()

For k = 1 To 60

Text3 = Text3 + Str(c(k)) + Space(2)

Next k

End Sub

Private Sub Form_Unload(Cancel As Integer)

Open & "" For Output As #1

Print #1,

Close #1

End Sub

强化 33

Private Sub Command1_Click()

Dim n As Integer

Cls

' ? = InputBox("请输入一个整数")

Print "因子数="; fun(n)

End Sub

Function fun(m As Integer)

Dim s As Integer

s = 0

For k = 1 To Abs(m) / 2

' If m Mod k = ? Then

s = s + 1

Print k

End If

Next k

' ?

End Function

2

Private Sub Command1_Click()

Dim k%

' For k = unt - 1 To 0 ?

If ed(k) = True Then

' m ?

' Item ?

End If

Next k

End Sub

Private Sub Command2_Click()

Dim k%

Text1 = "已经选中的城市有:"

For k = 0 To unt - 1 Step 1

' Text1 = ? & " " & (k)

Next k

End Sub

3

Dim stepy As Integer '纵向移动增量

Dim stepx As Integer '横向移动增量

Const LEFT_BUTTON = 1

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As

Single, y As Single)

Dim x0 As Integer, y0 As Integer, a As Single, radius As Integer

radius = / 2 '圆的半径

If Button = LEFT_BUTTON Then

x0 = + radius '圆心的x坐标

y0 = + radius '圆心的y坐标

If x = x0 Then

stepy = Sgn(y - y0) * 50

' stepx = ?

Else

a = (y - y0) / (x - x0) '斜率

stepx = Sgn(x - x0) * 50

' ? = a * stepx

If Abs(stepy) > Abs(stepx) Then

stepy = Sgn(y - y0) * 50

stepx = stepy / a

End If

End If

' ? = True

Else

' ? = False

End If

End Sub

Private Sub Timer1_Timer()

' + stepx, + ?

End Sub

强化34

Dim a(10) As Integer

Private Sub Form_Load()

For i = 1 To 10

a(i) = Int(Rnd * 100)

Next

End Sub

Private Sub Command1_Click()

x = a(1)

y = a(1)

For i = 2 To 10

If = True Then

' If a(i) ? x Then

' ?= a(i)

End If

' ElseIf a(i) ? y Then

' ?= a(i)

End If

Next

If = True Then

n = x

Else

n = y

End If

End Sub

2

Private Sub List1_DblClick()

' Call MoveItem(?)

End Sub

Private Sub Command1_Click()

Call MoveAll

End Sub

Public Sub MoveItem(L1 As ListBox, L2 As ListBox)

' m ?

' Item ?

End Sub

Public Sub MoveAll()

' For i = 0 To ?

m (i)

Next

End Sub

3

Dim a(7, 7) As Integer

Private Sub Form_Load()

read

End Sub

Public Sub read()

Open & "" For Input As #1

Do While Not EOF(1)

For i = 1 To 7

For j = 1 To 7

Input #1, a(i, j)

Next j

Next i

Loop

Close #1

End Sub

Public Sub Save()

Open & "" For Output As #1

Print #1, n, n

Close #1

End Sub

Private Sub Command1_Click()

Dim Sum As Long

N = 7

Counter = 0

Sum = 0

' 考生输入代码开始

' 考生输入代码结束

Save

End Sub

强化35

Private Sub Command1_Click()

Dim n As Integer

Dim b As Integer

Dim a(3) As Integer

s = RTrim()

'n = ? ()

For i = 1 To n

'b = ? (Mid(s, i, 1))

'Select Case ?

Case 48 To 57

a(0) = a(0) + 1

Case 65 To 90

a(1) = a(1) + 1

Case 97 To 122

a(2) = a(2) + 1

End Select

Next

'For i = 0 To ?

'? = a(i)

Next

End Sub

2

Private Sub remove(La As ListBox, Lb As ListBox)

' For i = 0 To ? - 1

' m ?.List(i)

Next

' ?.Clear

End Sub

Private Sub Command1_Click()

Call remove(List1, List2)

End Sub

Private Sub Command2_Click()

Call remove(List2, List1)

End Sub

3

Dim a(10) As Integer

Public Sub Save()

Open & "" For Output As #1

Print #1, n

Close #1

End Sub

Private Sub Command1_Click()

Open & "" For Input As #1

' Do While Not ?

For i = 1 To 10

Input #1, a(i)

' s = s & ?

Next i

Loop

Close #1

n = s

End Sub

Private Sub Command2_Click()

For i = 1 To 10

s = s & Str(a(i))

Next i

n = s

Save

End Sub


本文标签: 考生 输入 是否