用VB循环语句分别编1到10得和、差、积
1到100之和、差、积
初级编程学员,请详细回答并解释
用VB循环语句分别编1到10得和、差、积
1到100之和、差、积
初级编程学员,请详细回答并解释
For i = 1 To 10
sum1 = sum1 + i
Next i
for j = 1 to 100
sum2 = sum2+i
next j
sum = sum1 +sum2
Print "和为:" & sum
cha = sum2 - sum1
Print "差为:" & cha
ji = sum1*sum2
Print "积为:" & j
这是我理解的题目意思,不知道是否正确
Private Sub Form_Click() Dim i As Integer Dim sum As Integer '保存和 Dim cha As Long '保存差 Dim j As Long '保存积
For i = 0 To 100 sum = sum + i Next i Print "1--100之间的整数和为:" & sum
For i = 1 To 100 cha = cha - i Next i Print "1--100之间的整数差为" & cha
End Sub