那位大侠帮我做几个VB(Visual Basic)的题目啊,很基础,但我不会

2024-12-19 11:08:27
推荐回答(3个)
回答1:

1.
Private Sub Command1_Click()
i = 1
While i <= 100
If i Mod 5 = 0 Or i Mod 7 = 0 Then Sum = Sum + i
i = i + 1
Wend
Print Sum
End Sub

2.
Private Sub Command1_Click()
For i = 1 To 7 Step 2
For j = 1 To i
Print "*";
Next
Print
Next
End Sub

3.
Private Sub Command1_Click()
f1 = 1
f2 = 1
Sum = 2
Do
fn = f1 + f2
f1 = f2
f2 = fn
Sum = Sum + fn
Loop Until fn = 144
Print Sum
End Sub

4.
Private Sub Command1_Click()
For i = 3 To 300 Step 3
Sum = Sum + i
Next
Print Sum
End Sub

5.
Private Sub Command1_Click()
P = 1
For i = 10 To 20
For j = 2 To i - 1
If i Mod j = 0 Then Exit For
Next
If j = i Then P = P * i
Next
Print P
End Sub

回答2:

你看前两题这样做行不?
第一题:
Dim i As Integer
Dim SUM As Long
i = 0
SUM = 0
While i <= 100
i = i + 1
If (i Mod 5 = 0) Or (i Mod 7 = 0) Then SUM = SUM + i
Wend
第二题:
Dim i As Integer
Dim j As Integer
For i = 1 To 4
For j = 1 To 2 * i - 1
Print "*";
Next j
Print
Next i

回答3:

2.
For i = 1 to 4
For j= 1 to 2*i-1
print "*";
next j
Print
Next i