帮做一下两道VB程序设计简单的题~

Option Explicit

Option Base 1

Private Sub Command1_Click()

' 1:求1+1/(1+2)+1/(2+3)+1/(3+4).....的前N项和

Dim N%, S!, i%

N = InputBox("N=", "输入", 5)

S = 0

For i = 1 To N

S = S + 1 / (i - 1 + i)

Next i

Print S

End Sub

Private Sub Command2_Click()

' 2:生成20个20-3000之间的随机数,每行5个,再下行输出其中除5余2并被3整除的数,并求它们的和

Dim a%(20), i%, S%

For i = 1 To 20

a(i) = Rnd() * (3000 - 20) + 20

Print a(i);

If i Mod 5 = 0 Then Print

Next i

For i = 1 To 20

If a(i) Mod 5 = 2 And a(i) Mod 3 = 0 Then

Print a(i);: S = S + a(i)

End If

Next i: Print: Print S

End Sub