VB上机模拟考试习题集(01-50)解答

  • 格式:doc
  • 大小:405.00 KB
  • 文档页数:47

1.1上机模拟试题1解答

1. 基本操作

(1) 略

(2) 程序代码如下:

Private Sub Command1_Click()

Image1.Picture = LoadPicture(App.Path & "\图片.jpg")

End Sub

Private Sub Command2_Click()

Image1.Picture = LoadPicture("")

End Sub

2. 简单操作

(1) 程序代码如下:

Private Sub Command2_Click()

Dim i As Integer, max As Integer, N As Integer

For i = 1 To 100

If a(i) = (Int(Sqr(a(i)))) ^ 2 Then

If a(i) > max Then

max = a(i)

End If

N = N + 1

End If

Next i

Text1.Text = CStr(max)

Text2.Text = CStr(N)

End Sub

(2)

' ? "a0001" 其中?改为:List1.AddItem

' For i = 0 To ? 其中?改为:List1.ListCount - 1

' List1.ListIndex = ? 其中?改为:i

' ? Text1.Text 其中?改为:List1.AddItem

' ? 其中?改为:End

3. 综合应用

' a(i) = Fix(Rnd * ? + 1) 其中?改为:100

' For j = 1 To ? 其中?改为:i - 1

' i = ? 其中?改为:i - 1

' If a(i) = ? Then 其中?改为:num

' If ? > 10 Then 其中?改为:i

1.2上机模拟试题2解答

1. 基本操作

(1) 略

(2) 程序代码如下:

Private Sub HS1_Change()

Text1.Width = HS1.Value 1 End Sub

2. 简单操作

(1)

' While (k < List2.?) 其中?改为:ListCount

' If ?.Selected(k) = True Then 中?改为:List2

' List2.RemoveItem ? 其中?改为:k

' List1.RemoveItem List1.? 其中?改为:List1.ListIndex

(2) 程序代码如下:

Private Sub C1_Click()

For i = 0 To 2

If Op1(i).Value = True Then

n = Left(Op1(i).Caption, 2)

t = 1

For j = 1 To n

t = t * j

Next j

End If

Next i

Text1 = t

End Sub

3. 综合应用

' CD1.FilterIndex = ? 其中?改为:2

' Text1.Text = ? 其中?改为:a

' CD1.Action = ? 其中?改为:2

程序代码如下:

Private Sub C2_Click()

Text1.Text= UCase(Text1.Text)

End Sub

1.3上机模拟试题3解答

1. 基本操作

(1) 略

(2) 程序代码如下:

Private Sub C1_Click()

Text2.Text = Text1.Text

End Sub

2. 简单操作

(1)

' S1 = ? 其中?改为:Text1.Text

' Do While Mid(S1, I1, 1) <> ? And I1 <= Len(S1) 其中?改为:" "

' List1.AddItem ? 其中?改为:S2

' S2 = ? 其中?改为:""

(2) 程序代码如下:

' For i = ? To Cb1.ListCount - 1其中?改为:0

' If Cb1.List(i) = Cb1.? Then 其中?改为:Text

' Cb1.? Cb1.Text 其中?改为:AddItem 2

3. 综合应用

程序代码如下:

Private Sub Form_Load()

Dim str As String

Open App.Path + "\in5.txt" For Input As #1

Do While Not EOF(1)

Input #1, str

Text1.Text = Text1.Text + str

Loop

Close #1

End Sub

Private Sub C1_Click()

Open App.Path + "\out5.txt" For Output As #2

Print #2, Text1.Text

Close #2

End Sub

1.4上机模拟试题4解答

1. 基本操作

(1) 略

(2) 程序代码如下:

Private Sub Command1_Click()

Shape1.Shape = 3

End Sub

Private Sub Command2_Click()

Shape1.BorderColor = &HFF&

End Sub

2. 简单操作

(1)

' Select Case ? 其中?改为:Index

' Timer1.Enabled =? 其中?改为:True

' If Picture1.Left + Picture1.Width >= ? Then 其中?改为:Form2.Width

' Picture1.Left = ? 其中?改为:0

(2)

' If ? = True Then 其中?改为:Option1.Value = True

' If ? = True Then 其中?改为:Option3.Value = True

' Label2.Caption = ? 其中?改为:s

3. 综合应用

程序代码如下:

Private Sub Command1_Click()

'====考生编写程序开始====

Dim i As Integer, j As Integer, max As Integer

max = a(1, 1)

For i = 1 To 4

For j = 1 To 4 3 If max < a(i, j) Then max = a(i, j)

Next j

Next i

Label3.Caption = max

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

'不得修改以下部分

save Label3

End Sub

Private Sub Command2_Click()

'====考生编写程序开始====

Dim i As Integer, j As Integer, sum As Integer

sum = 0

For i = 1 To 4

For j = 1 To 4

If i = j Then sum = sum + a(i, j)

Next j

Next i

Label4.Caption = sum

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

'不得修改以下部分

save Label4

End Sub

1.5上机模拟试题5解答

1. 基本操作

(1) 略

(2) 程序代码如下:

Private Sub Command1_Click()

Timer1.Enabled = True

End Sub

Private Sub Command2_Click()

Timer1.Enabled = False

End Sub

Private Sub Command3_Click()

Call sub1

End Sub

Private Sub Timer1_Timer()

Text1.Text = Text1.Text + 1

End Sub2.

简单操作

(1)

' For i = 1 To ? 其中?改为:5

' For j = 1 To ? 其中?改为:2 * i - 1 4 ' For j = 1 To ? 其中?改为:i + 1

' For j = 1 To ? 其中?改为:9 - 2 * i

(2)

' ? = False 其中?改为:Timer1.Enabled

' Shape2.Top = ? + d * 50 其中?改为:Shape2.Top

' If Shape2.Top <= Shape1.? Or Shape2.Top + Shape2.Width >= Shape1.Top +

Shape1.Height Then 其中?改为:Top

' Shape2.Left = ? + d * 50 其中?改为:Shape2.Left

3. 综合应用

' n = n + ? 其中?改为:1

' List1.AddItem ? 其中?改为:ch$

程序代码如下:

Private Sub Command2_Click()

'需要考生编写的内容

Dim x As Single, p As Single

x = Val(Text1.Text)

If x < 500 Then

p = 1

ElseIf x < 1000 Then

p = 0.98

ElseIf x < 1500 Then

p = 0.95

ElseIf x < 2000 Then

p = 0.92

Else

p = 0.9

End If

Text2.Text = CStr(Int(x * 0.3 * p))

End Sub

Private Sub List1_Click()

'需要考生编写的内容

Dim i As Integer