-
Case 4
WeekDay=”星期四 ” Case 5
WeekDay=”星期五 ” Case 6
WeekDay=”星期六 ” End Select End Function
5.Function Rand30(ByVal X As`Integer) As Integer Randomize
Rand30=Int(Rnd*X+1) End Function
Sub Command1_Click() For i=1 To 30 Print Rand30(100) Next i End Sub
6.Function F1(ByVal X As`Single, ByVal Y As`Single) As Integer If X>Y Then F1=X Else F1=Y End If End Function 7.
Function GDBH(ByVal x%) As String Dim i%
For i = 3 To x - 3 Step 2 If isp(i) And isp(x - i) Then GDBH = i & \Exit Function End If Next End Function
Function isp(y%) As Boolean i = 2: k = Int(y / 2)
-
-
Do While i <= k
If y Mod i = 0 Then Exit Do i = i + 1 Loop
If i > k Then
-
-
isp = True Else isp = False End If End Function
Private Sub Form_Click() For i = 6 To 40 Step 2 Print GDBH(i) Next i End Sub
8.Function isQO(ByVal x As Integer) As String If x Mod 2 =0 Then isQO= ”偶数 ” Else
isQO= ”奇数 ” End If End Function
9.Function F1(ByVal x As Integer) As Boolean If x Mod 17 =0 and x Mod 37 =0Then F1=True Else F1=False End If End Function
Private Sub Form_Click() For i = 1000 To 2000 If F1(i) Then Print i End if Next i End Sub
10. Sub F1(a() As Integer, ByVal L1 As Integer, ByVal L2 As Integer)
-
-
Dim L%, U%, x%, i%
L = LBound(a): U = UBound(a) If L1 > U Or L2 > U Then Print \位置输入错误! \Exit Sub
-
-
End If
If L1 > L2 Then x = a(L1)
For i = L1 To L2 + 1 Step -1 a(i) = a(i - 1) Next i a(L2) = x
ElseIf L2 > L1 Then x = a(L1)
For i = L1 To L2 - 1 a(i) = a(i + 1) Next i a(L2) = x End If End Sub
第九章 习题参考答案 一、选择题: 1—3: ADD 二、填空题 1.下拉式 弹出式 2.PopupMenu 3.Visible Enabled 4 . - 三、编程题 (略 )
第十章 习题参考答案 一、选择题: 1—3: DBD 二、填空题
1.Load 2.窗体模块 标准模块 3.DoEvents 三、编程题 1.(略 )
2.Function F(ByVal x&,ByVal Y&) As Integer Dim t&,r&
If x
-
类模块