1樓:匿名使用者
'我也很無聊。。。。
dim result as long
dim n as integer
'初始化result、n
result = 1
n = cint(text1.text)
'使用while
while n > 0
result = result * n
n = n -1
loop
''使用for
'dim i as integer
'for i =1 to n
' result = result * i'next
'輸出結果result
msgbox result
'更無聊的事情來了,做一個textbox驗證輸入合法類mychk_textbox.cls
'以下為火星文
啊啊啊大時代大烤鴨的哦盤
vb中求1到n階乘的和
2樓:捌零老陳
sum = 0
temp = 1
for i = 1 to n
sum = sum + temp * i
temp = temp * i
next
用vb怎樣求n的階乘和
3樓:匿名使用者
public function jiecheng(byval n as integer) as integer
dim jc as integer = 1for i = 1 to n
jc = jc * i
next
return jc
end function
用vb程式設計計算:1!+2!+3!+4!+…+n!
4樓:匿名使用者
新建一個工程,新增個命令按鈕和一個文字框
**如下:
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計算出n!+(n+1)!+(n+2)!+...+(n+m)!
5樓:匿名使用者
private sub command1_click()for i = val(text1.text) to val(text1.text) + val(text2.text)
s = s + factorial(i)
next i
label3.caption = "summation=" & send sub
private function factorial(byval num as integer) as double
factorial = 1
for i = 1 to num
factorial = factorial * inext i
end function
6樓:匿名使用者
dim su as long
for i = 0 to m
su = su + ch(n + i)
next i
private function ch(n as integer) as long
dim i as integer
ch = 1
for i = 1 to n
ch = ch * i
next n
end function
用vb編寫程式,計算
option explicitdim k,t as singleprivate sub mand1 click for k 2 to 300 step 2t t 1 k next label1.caption t end sub for i 2 to 300 step 2 sum 1 i sum n...
vb公式計算
輸出倒是比較簡單 for i 0 to 360 y i x a x b z i c z i 表示,分別與x對應的取值,y i 方便用來儲存這麼多數值 print y i y後面可以加逗號或者分號等,這樣不至於每個y都是一行,361行,vb介面可以顯示不完整。記得把窗體屬性的autoredraw為tr...
計算機vb問題答案,計算機VB問題答案
y n 2 m if y 0 then msgbox 腳數必定 只數的2倍,請重新輸入 text2 text2.setfocus else x m y lable2 x lable3 y end if end if end sub 第一題private sub text2 lostfocus dim...