1、【
简答题】
Private Sub Command1_Click()
Dim n As Integer
Cls
' ? = InputBox("请输入一个整数")
n = 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
If m Mod k = 0 Then
s = s + 1
Print k
End If
Next k
' ?
fun = s
End Function
[10分]
解析:
' n
' 0
' fun = s
2、【
简答题】
[10分]
解析:
按要求解答即可
3、【
简答题】
Private Function IsPrime(ByVal x As Integer) As Boolean
Dim i As Integer
For i = 2 To Sqr(x)
If x Mod i = 0 Then
IsPrime = False
Exit Function
End If
Next
IsPrime = True
End Function
Private Sub Command1_Click()
'考生编写程序开始
'======================================
????
'=========================================
'考生编写程序结束
Open App.Path & "\out5.dat" For Output As #1
Print #1, Text1.Text, Label1.Caption, Label2.Caption
Close #1
End Sub
[10分]
解析:
Dim i As Integer
Dim n As Integer
n = Val(Text1.Text)
If n Mod 2 <> 0 Then
MsgBox "请输入偶数!"
Exit Sub
End If
For i = 3 To n / 2
If IsPrime(i) And IsPrime(n - i) Then
Label1.Caption = i
Label2.Caption = n - i
Exit For
End If
Next
4、【
简答题】
[10分]
解析:
按要求解答即可
5、【
简答题】
Private Sub Command1_Click()
Dim st$, ch$
Open App.Path & "\in3.txt" For Input As #1
Do While Not EOF(1)
Input #1, ch
' st = ? & ch
Loop
Close #1
Text1 = st
End Sub
Private Sub Command2_Click()
Dim st$, word$, c$
st = Text1
n = Len(st)
For k = 1 To n
' ? = Mid(st, k, 1)
If c <> " " Then
word = word & c
Else
List1.AddItem word
' ? = ""
End If
Next
List1.AddItem word
End Sub
[10分]
解析:
st = st & ch
c = Mid(st, k, 1)
word = ""
6、【
简答题】
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 = Shape1.Width / 2 '圆的半径
If Button = LEFT_BUTTON Then
x0 = Shape1.Left + radius '圆心的x坐标
y0 = Shape1.Top + 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()
' Shape1.Move Shape1.Left + stepx, Shape1.Top + ?
End Sub
[10分]
解析:
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 = Shape1.Width / 2 '圆的半径
If Button = LEFT_BUTTON Then
x0 = Shape1.Left + radius '圆心的x坐标
y0 = Shape1.Top + radius '圆心的y坐标
If x = x0 Then
stepy = Sgn(y - y0) * 50
stepx = 0
Else
a = (y - y0) / (x - x0) '斜率
stepx = Sgn(x - x0) * 50
stepy = a * stepx
If Abs(stepy) > Abs(stepx) Then
stepy = Sgn(y - y0) * 50
stepx = stepy / a
End If
End If
Timer1.Enabled = True
Else
Timer1.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
Shape1.Move Shape1.Left + stepx, Shape1.Top + stepy
End Sub
7、【
简答题】
[10分]
解析:
Private Sub Command1_Click()
Text1.PasswordChar = ""
End Sub
Private Sub Command2_Click()
Text1.PasswordChar = "*"
End Sub
Private Sub Command3_Click()
Text1 = ""
Text1.SetFocus
End Sub
8、【
简答题】
Private Sub Command1_Click()
Dim k%
' For k = List1.ListCount - 1 To 0 ?
If List1.Selected(k) = True Then
' List2.AddItem ?
' List1.RemoveItem ?
End If
Next k
End Sub
Private Sub Command2_Click()
Dim k%
Text1 = "已经选中的城市有:"
For k = 0 To List2.ListCount - 1 Step 1
' Text1 = ? & " " & List2.List(k)
Next k
End Sub
[10分]
解析:
For k = List1.ListCount - 1 To 0 Step -1
List2.AddItem List1.List(k)
List1.RemoveItem k
Text1 = Text1 & " " & List2.List(k)
9、【
简答题】
Private Sub C1_Click()
Timer1.Enabled = ?
End Sub
Private Sub C2_Click()
? = False
End Sub
Private Sub Timer1_Timer()
P1.Move P1.Left + ?
End Sub
[10分]
解析:
Private Sub C1_Click()
Timer1.Enabled = True
End Sub
Private Sub C2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
P1.Move P1.Left + 20
End Sub
10、【
简答题】
[10分]
解析:
Private Sub Command1_Click()
Text2.Text = Form1.Text1.SelLength
End Sub