第二题:
Private Sub Command1_Click()
Timer1.Interval = 500
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Dim r As Integer, g As Integer, b As Integer
r = Int(Rnd * 256)
g = Int(Rnd * 256)
b = Int(Rnd * 256)
Text1.BackColor = RGB(r, g, b)
End Sub
'10元和50元两种纸币组成240元,列出所有不同的取法和种数.Private Sub Command1_Click()
Dim a%, b%, count%
For a = 1 To 19
For b = 1 To 4
If a * 10 + b * 50 = 240 Then
Print a"张10元和"b"张50元"
count = count + 1
End If
Next b
Next a
Print "共有"count"种不同的取法"
End Sub
'1xx47 ,知道这5位数是57或67的倍数,输出所有满足条件的5位数,并统计这样数的个数.
Private Sub Command1_Click()
Dim i%, count%
For i = 10047 To 19947 Step 100
If i Mod 57 = 0 Or i Mod 67 = 0 Then
Print i
count = count + 1
End If
Next
Print "共有"count"个这样的数"
End Sub
'鸡兔同笼共50只,有腿160只,求鸡和兔各多少只?
Private Sub Command1_Click()
Dim x As Integer
Dim y As Integer
h = 50
f = 160
x = 2 * h - f / 2
y = f / 2 - h
MsgBox "鸡的只数为:" &x &vbCrLf &"兔子的只数为:" &y
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)