1樓:匿名使用者
private sub command1_click()dim n as integer , i as integer, s as integer , l as integer, k as integer
n = val(inputbox(""))for l = 1 to n
s = 1
for i = l to 1 step -1s = s * i
next i
k = k + s
next l
print k
end sub
2樓:匿名使用者
dim s as integer '階乘總和dim num as ingeger '價乘s=0
num=1
for i=1 to n
num=num*i
s=s+num
next i
樓上的方法是可以就是有點麻煩
3樓:
n=cint(inputbox("請輸入n"))s=0for i=1 to n
x=1for j=2 to i
x=x*j
next
s=s+x
next
print "s=";s
4樓:
dim i as integer
dim n as integer
dim m as integer
dim t as long
dim s as long
n=val(inputbox())
s=0for i=1 to n
t=1for m=1 to i
t=t*i
next m
s=s+t
next i
print s
5樓:匿名使用者
兩個函式 :1,求階乘
2,累加
用vb程式設計計算:1!+2!+3!+4!+…+n!
6樓:匿名使用者
新建一個工程,新增個命令按鈕和一個文字框
**如下:
private sub command1_click()n = val(text1.text)
s = 0 '存結果
for i = 1 to n
t = 1 '臨時存積的變數
for j = 1 to i '計算階乘
t = t * j
next j
s = s + t
next i
print "結果為:" & s
end sub
使用vb程式設計計算s=1+2+3.......+n(n 的值由於使用者定)寫程式
7樓:鯤鵬展翅
dim n as integer
dim i as long
dim ssum as long
n=vol(inputbox())
for i = 1 to n
ssum = ssum + i
next
msgbox ssum
8樓:匿名使用者
private sub form_load()dim a as string
dim i as long
dim ssum as long
a = inputbox("123", "123", 1)if isnumeric(a) then
for i = 1 to a
ssum = ssum + i
next
end if
msgbox ssum
end sub
9樓:宛丘山人
input 「請輸入最大值n" n
s=0for i=1 to n
s=s+i
next i
print "s=";s
10樓:匿名使用者
private sub form_load()dim n as integer
n = val(inputbox("input a number", "inputbox", "10"))
msgbox fun(n)
end sub
private function fun(n as integer) as integer '遞迴
if n <= 1 then
fun = 1
else
fun = n + fun(n - 1)
end if
end function
11樓:讀書沒鳥用
dim a as integer,s as integern=val(inputbox(「請輸入」))for i=1 to n
s=s+i
next i
print s
12樓:匿名使用者
c語言程式設計,s 1 2 3n ,其中n由鍵盤
int main int argc,char argv s temp printf ns d s return 0 c語言程式設計題 s 1 2 3 4 5 n n由鍵盤輸入 求迴圈過程 這是我們以前做過 的課後習題 include int main printf d n s return 0 c語...
VB程式設計如何計算平均數,用vb程式計算三個數的平均值 程式碼要簡單易懂的,本人菜鳥
新建工程,1個文字框和1個按鈕 text1用來錄入資料,因為是任意個數,用很多文字框是不方便的,程式設計是使用 來分隔數字,你可以輸入任意多個數字,然後按鈕command1後,就可以顯示總和及平均值.private sub command1 click if len text1 0 then exi...
求大神用vb給我解決一下第一題,用vb程式設計實現怎麼是實現第一題?求大神幫助
dim i as integer dim j as integer dim temp as integer private sub command1 click dim s as string s print 原陣列為 for i 1 to 10 s s a i next i print s pri...