以下程序均不需设置属性。
1、
For i = 1 To 1000
If i Mod 7 = 0 Then c = c + 1
Next i
Print c
2、
a = 1
For i = 1 To 9
a = a * i
If i Mod 2 <> 0 Then s = s + a
Next i
Print s
3、
For i = 1 To 7
Print Spc(i - 1);
For j = 1 To (15 - 2 * i)
Print "*";
Next j
Print
Next i
4、
For i = 100 To 999
If (i Mod 10) ^ 3 + (i \ 10 Mod 10) ^ 3 + (i \ 100) ^ 3 = i Then Print i
Next i
'建立一个command1控件组(0-4),其它不用任何设定
Option Explicit
Dim I As Integer, J As Integer, C As Single, Jc As Single
Private Sub Command1_Click(Index As Integer)
Cls
Select Case Index
Case 0
Print "1000以内所有能被7整除的数是:"
C = 0
For I = 1 To 1000
If I Mod 7 = 0 Then
C = C + 1
If C Mod 10 = 0 Then Print
Print I;
End If
Next I
Print
Print "共有:"; C; "个"
Case 1
C = 0
For I = 1 To 9 Step 2
Jc = 1
For J = 1 To I
Jc = Jc * J
Next
Print I; "的阶乘是:"; Jc
C = C + Jc
Next I
Print "1!+3!+5!+7!+9!="; C
Case 2
For I = 1 To 7
Print Tab(I);
For J = 1 To 15 - 2 * I
Print "*";
Next J
Print
Next I
Case 3
Print "水仙花数是:"
C = 0
For I = 100 To 999
Jc = (I Mod 10) ^ 3 + ((I \ 10) Mod 10) ^ 3 + (I \ 100) ^ 3
If Jc = I Then
Print I;
C = C + 1
End If
Next I
Print
Print "共有:"; C; "个"
Case 4
End
End Select
End Sub
Private Sub Form_Load()
Form1.AutoRedraw = True
Command1(0).Caption = "被七整除"
Command1(1).Caption = "计算阶乘"
Command1(2).Caption = "输出图形"
Command1(3).Caption = "水仙花数"
Command1(4).Caption = "退出"
End Sub
'已经运行过。
第一个题
Private Sub Command1_Click()
Dim num7 As Integer
num7 = 0
For i = 0 To 1000
If i Mod 7 = 0 Then
num7 = num7 + 1
Label2.Caption = num7
End If
Next
End Sub
这个用C做起来更简单,你试一下!