English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

我想寫出這樣的結果來:2*3*4+5*6*7+8*9*10+…+20*21*22
這是我寫出的片段
Option Explicit
Private Sub Form_Activate()
Dim Sum, N, k, j, P As Integer
Dim total As Long
Sum = 1
P = 1
k = 0
For N = 2 To 4
Sum = k + (N * Sum)
Next N
For j = 5 To 7
P = k + (j * P)
Next j
total = Sum + P
Print "Total="; total
End Sub
後面的部份因該怎麼寫呢~~謝謝謝!

2005-08-09 10:48:55 · 3 個解答 · 發問者 Anonymous in 電腦與網際網路 程式設計

3 個解答

  Dim i As Integer, s As Integer
  For i = 2 To 22 Step 3
    s = s + (i * (i + 1) * (i + 2))
  Next
  Print s

2005-08-09 18:57:28 · answer #1 · answered by Anonymous · 0 0

底線大大的解法不錯

給上官大大跟發問者:
請注意在VB6.0版本的變數宣告
Dim A,B,C As String
A跟B變數都將是Variant,C才是字串
正確應該這樣
Dim A As String,B As String,C As String
當然我的話都是
Dim A$,B$,C$

據說.NET版本有改了
程式問題歡迎到初新者討論區討論
http://willh.org/cfc

2005-08-10 06:51:06 · answer #2 · answered by Anonymous · 0 0

Dim n, sum1, sum2 As Integer
Private Sub Form_Activate()
For i = 2 To 22
n = n + 1
sum1 = sum1 * i
If n = 3 Then
n = 0
sum2 = sum2 + sum1
sum1 = 1
End If

Next i
Print sum2

End Sub

Private Sub Form_Load()
n = 0: sum1 = 1: sum2 = 0


End Sub

2005-08-09 11:13:46 · answer #3 · answered by 上官 5 · 0 0

fedest.com, questions and answers