Private x As Integer
Private Sub Command1_Click()
x = Val(InputBox("请输入正整数"))
End Sub
Private Sub Command2_Click()
Select Case Combo1.ListIndex
Case 0
MsgBox Str(x) & f1(x)
Case 1
MsgBox Str(x) & f2(x)
Case Else
Exit Sub
End Select
End Sub
Private Function f1(ByVal x As Integer) As String
If x \ 2 <> x / 2 Then
f1 = "是奇数"
Else
f1 = "是偶数"
End If
End Function
Private Function f2(ByVal x As Integer) As String
If x Mod 7 = 0 Then
f2 = "能被7整除"
Else
f2 = "不能被7整除"
End If
End Function
Private Flag As Boolean
Private Sub Form_Click()
If Flag Then
Shape1.Top = Shape2.Top
Shape1.Left = Shape2.Left
Flag = Not (Flag)
Else
Shape1.Top = Shape2.Top + Shape2.Height - Shape1.Height
Shape1.Left = Shape2.Left + Shape2.Width - Shape1.Width
Flag = Not (Flag)
End If
End Sub
Private Sub Form_Load()
Flag = True
End Sub
Dim a(10) As Integer
Dim b(10) As Integer
Dim c(10) As Integer
Private Sub Command1_Click()
Open App.Path & "\dataA.txt" For Input As #1
Open App.Path & "\dataB.txt" For Input As #2
For i = 0 To 9
Input #1, a(i)
Input #2, b(i)
Next
Close #1, #2
End Sub
Private Sub find(x() As Integer, t As TextBox)
Max = x(1)
For i = 2 To UBound(x)
If x(i) > Max Then
Max = x(i)
End If
Next
t.Text = Max
End Sub
Private Sub Command2_Click()
For i = 1 To UBound(a)
c(i) = a(i) + b(i)
Next
Open App.Path & "\out51.txt" For Output As #1
For i = 0 To 9
Print #1, c(i)
Next
Close #1
End Sub
Private Sub Command3_Click()
Call find(a, Text1)
Call find(c, Text2)
Open App.Path & "\out52.txt" For Output As #1
Print #1, Text1.Text, Text2.Text
Close #1
End Sub
展开阅读全文