一道有关vb编程的题目

2025-01-07 05:41:59
推荐回答(4个)
回答(1):

Private Sub Form_Click()
For i = 100 To 1000
If i Mod 37 = 0 Then Print i
Next i
End Sub

第二题
Private Sub Form_Click()
Dim n As Integer, i As Integer, a As Integer
n = Val(InputBox("请输入n的值"))
For i = 1 To n
a = a + sum(i)
Next i
Print a
End Sub

Private Function sum(n As Integer)
sum = 0
For i = 1 To n
sum = sum + i
Next i
End Function

回答(2):

Private Sub Command1_Click()
For i = 100 To 1000
If i Mod 37 = 0 Then
Print i
End If
Next i
End Sub

回答(3):

2/
Private Sub Form_Click()
Dim n As Integer, a As Integer, sum as integer
n = Val(InputBox("请输入N的值"))
For i = 1 To n
a = a + i
sum = sum + a
next i
print sum
End Sub

回答(4):

'(1)(2)两题
Private Sub Form_load()
Form1.WindowState = 2: Me.Show: Print "能被37整除的数:"
For i = 100 To 1000
If i Mod 37 = 0 Then
Me.Show: Print " " & i: End If
Next i: n = Val(InputBox("请输入N的值"))
For i = 1 To n
a = a + i: Sum = Sum + a
Next i
Print Chr(13) & "S=" & Sum
End Sub