求帮忙编一个简单的程序,用VB可以吗,不用太复杂,能用就行了

2024-11-16 09:16:17
推荐回答(1个)
回答(1):

T1 参考http://zhidao.baidu.com/question/439422571.html

T2
Dim i, a, b As Integer
a = CInt(Text1.Text)
For i = 0 To a
b = b + 2 * i + 1
Next i
MsgBox "总和=" & b, , "结果"

T3
Dim i, j, k As Integer
Dim p As Boolean
Dim a, b As Integer
k = 1
b = 1
a = 200 '设定上限
For i = 2 To a
p = False
For j = 2 To a
If j >= i Then Exit For
If i Mod j = 0 Then p = True
Next j
If p = False Then
Print i;
b = b + i
If k Mod 5 = 0 Then Print
k = k + 1
End If
Next i
Print
Print "Sum = " & b