1、【
简答题】
[10分]
解析:
Option Base 1
Function Fun(a() As Single) As Single
Sum = 0
For i = 1 To UBound(a)
Sum = Sum + a(i) / i
Next i
Fun = Sum
End Function
Private Sub Command1_Click()
Dim arr
Dim arr2(40) As Single
arr = Array(12.5, 65.4, 56, 73, 46.23, 58.25, 83.49, 96, 27.3, 36.78, _
29.26, 89.4, 34.7, 45.4, 56.9, 67.4, 78, 98, 87.5, 76.8, _
34.6, 55.8, 64.7, 43.7, 99.4, 84.7, 66.2, 23.9, 55.5, 44.1, _
33.2, 43.5, 41.2, 28.3, 78.6, 98.3, 56.1, 73.6, 49.3, 48.3)
For i = 1 To UBound(arr)
arr2(i) = arr(i)
Next i
r = Fun(arr2())
Text1.Text = Str(r)
SaveData
End Sub
Sub SaveData()
Open App.Path & "\out3.txt" For Output As #1
Print #1, Text1.Text
Close 1
End Sub
2、【
简答题】
[10分]
解析:
Private Sub C1_Click()
C2.Visible = True
C1.Visible = False
End Sub
Private Sub C2_Click()
C1.Visible = True
C2.Visible = False
End Sub
3、【
简答题】
[10分]
解析:
Private Sub Command1_Click()
Const PI = 3.14159
Select Case Combo1.Text
Case "sin": a = Sin(CInt(Text1.Text) * PI / 180)
Case "cos": a = Cos(CInt(Text1.Text) * PI / 180)
Case "tg": a = Tan(CInt(Text1.Text) * PI / 180)
Case "ctg": a = 1 / Tan(CInt(Text1.Text) * PI / 180)
' Case "tg": a = Sin(CInt(Text1.Text) * PI / 180) / Cos(CInt(Text1.Text) * PI / 180)
' Case "ctg": a = Cos(CInt(Text1.Text) * PI / 180) / Sin(CInt(Text1.Text) * PI / 180)
End Select
Text2 = Int(a * 1000) / 1000
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call mysub
End Sub
4、【
简答题】
Dim an As Integer
Dim bn As Integer
Dim cn As Integer
Dim dn As Integer
Private Sub Command1_Click()
Open App.Path & "\in5.txt" For Input As #1
Do While Not EOF(1)
Input #1, a$
s = s & a$
Loop
Close 1
Text1.Text = s
End Sub
[10分]
解析:
Private Sub Command2_Click()
'考生应编写的程序
n = Len(Text1)
For k = 1 To n
ch = Mid(Text1, k, 1)
If UCase(ch) = "A" Then
an = an + 1
End If
If UCase(ch) = "B" Then
bn = bn + 1
End If
If UCase(ch) = "C" Then
cn = cn + 1
End If
If UCase(ch) = "D" Then
dn = dn + 1
End If
Next k
Text1 = an & " " & bn & " " & cn & " " & dn
End Sub
Private Sub Command3_Click()
Open App.Path & "\out5.txt" For Output As #1
Print #1, an, bn, cn, dn
Close 1
End Sub
5、【
简答题】
[10分]
解析:
Dim a%, b As Boolean
Private Sub C1_Click()
Timer2.Enabled = True
b = True
End Sub
Private Sub Timer1_Timer()
a = a + 1
If a > 6 Then
a = 1
End If
Select Case a
Case 1
P1.Picture = LoadPicture("黄灯.ico")
Case 2, 3
P1.Picture = LoadPicture("红灯.ico")
Case 4, 5, 6
P1.Picture = LoadPicture("绿灯.ico")
If b Then Timer2.Enabled = True
End Select
End Sub
Private Sub Timer2_Timer()
If (a < 4) And (P2.Left > P1.Left And P2.Left < P1.Left + P1.Width) Or P2.Left <= 100 Then
Timer2.Enabled = False
Else
P2.Move Form1.P2.Left - 10, P2.Top, P2.Width, P2.Height
End If
End Sub
6、【
简答题】
[10分]
解析:
Private Sub Command1_Click()
'Text2 = Text1.SelText
'或
Me.Text2.Text = Form1.Text1.SelText
End Sub
Private Sub Command2_Click()
Form1.Text1.SelText = ""
End Sub
7、【
简答题】
Private Sub Form_Load()
Command1.Caption = "开始"
Command2.Caption = "停止"
Timer1.Interval = 50
Timer1.Enabled = False
Label1.Caption = "热烈欢迎"
Label1.AutoSize = True
Label1.FontSize = 16
Label1.FontBold = True
End Sub
Private Sub Command1_Click()
Command1.Caption = "继续"
' Timer1.Enabled = ?
'Command1.Enabled = ?
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
' Timer1.Enabled = ?
Command2.Enabled = False
Command1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Label1.Left < Width Then
' Label1.Left = ?
Else
Label1.Left = 0
End If
End Sub
[10分]
解析:
Private Sub Form_Load()
Command1.Caption = "开始"
Command2.Caption = "停止"
Timer1.Interval = 50
Timer1.Enabled = False
Label1.Caption = "热烈欢迎"
Label1.AutoSize = True
Label1.FontSize = 16
Label1.FontBold = True
End Sub
Private Sub Command1_Click()
Command1.Caption = "继续"
Timer1.Enabled = True
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Command2.Enabled = False
Command1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Label1.Left < Width Then
Label1.Left = Label1.Left + 20
Else
Label1.Left = 0
End If
End Sub
8、【
简答题】
Dim num
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
' num = ?
If num < 60 Then
If Option1.Value = True Then
Text2.Text = num
Else
If (num / 10 = CInt(Int(num / 10))) Then
' Text2.Text = Text2.Text + ?
End If
End If
Else
Text2.Text = 0
num = 0
' Text1.Text = Text1.Text + ?
End If
End Sub
[10分]
解析:
Dim num
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
num = num + 1
If num < 60 Then
If Option1.Value = True Then
Text2.Text = num
Else
If (num / 10 = CInt(Int(num / 10))) Then
Text2.Text = Text2.Text + 10
End If
End If
Else
Text2.Text = 0
num = 0
Text1.Text = Text1.Text + 1
End If
End Sub
9、【
简答题】
[10分]
解析:
Private Sub Form_Click()
L1.AddItem Str$(Form1.HS1)
End Sub