1樓:匿名使用者
private sub command1_click()
dim a1: dim a2 '定義兩個變數
for i = 2 to 10 step 2 '使用for迴圈,每次加2
a1 = 1 '算完一個偶數的階乘,中間變數初始化,供下次迴圈使用
for a = i to 1 step -1 '利用for迴圈,計算每個偶數的階乘
a1 = a1 * a '具體計算
next a '具體計算
a2 = a2 + a1 '變數a2用來儲存已運算過的偶數階乘的和
next i '繼續運算下一個偶數
msgbox "程式運算結果為: " & a2 '得到結果
end sub
2樓:
這樣效率最高:
private sub form_load()dim sum&,n&,i%
n=1for i=2 to 10 step 2n=n*i*(i-1)
sum=sum+n
next
msgbox sum
end sub
3樓:guoxin愛記錄
private sub command1_click()dim sum as long, n as longfor i = 2 to 10 step 2n = 1
for j = i to 1 step -1n = n * j
next j
sum = sum + n
next i
print "the result is :" & sumend sub
4樓:匿名使用者
dim sum as long
dim n as long
dim i as integer
n = 1
for i = 1 to 10
n = n * i
if i mod 2 = 0 then
sum = sum + n
end if
next
msgbox sum
VB程式設計題目,vb程式設計題目
private sub mand1 click dim i as integer,j as integer,k as integer dim a 1 to 10 as integerdim max as integer,min as integer,pj as single dim sumnum a...
vb程式設計問題,VB程式設計問題
private sub command1 click text1 for i 1 to 45 7 for j 1 to 45 6 2for k 1 to 45 3 5if i j 2 k 5 45 thenn n 1 end if next next next text1 n end sub pri...
VB程式設計問題,VB程式設計難嗎?
非常簡單,你看插圖,一切都在圖中。如下 在窗體中新增一個label1 兩個預設command1和command2。一切屬性預設 不用修改。private sub command1 click if command1.caption 有邊框 then label1.borderstyle 1 comm...