1樓:我的月亮沒了
private sub zgc(x, diff)dim i as integer
for i = 3 to x
if i mod 2 then
diff = diff - 1 / i
else
diff = diff + 1 / i
end if
next i
end sub
private function zhs(x) as doubledim i as integer
for i = 3 to x
if i mod 2 then
diff = diff - 1 / i
else
diff = diff + 1 / i
end if
next i
zhs = diff
end function
private sub command1_click()dim diff as double
diff = 0
zgc val(text1.text), diffprint "子過程:"; diff
diff = 0
diff = zhs(val(text1.text))print "子函式:"; diff
end sub
2樓:牛人影視
function myfun(n as integer) as long
dim i as integer
dim s as long
s=0for i=2 to n step 2s=s+1/i
next
for i=3 to n step 2
s=s-1/i
next
myfun=s
end function
3樓:匿名使用者
private function f(n as integer) as integer
dim i as integr
sum as single
for i=2 to n
sum=sum+1/i
next
f=sum
end function
vb程式設計計算1+1/2!+1/3!+1/4!+1/5!的值
4樓:哪呢
private sub command1_clickdim s as integer, i as integer, c as integer
s=0c=1
for i =1 to 5
c=c*i
s=s+i/c
next i
5樓:會飛滴包子
private sub command1_click()n=inputbox("請輸
入n:")
dim a as integer
a = 1
dim sum as double
for i = 1 to n
for j = 1 to i
a = a * j
next
sum = sum + 1 / a
a = 1
next
print sum
end sub
vb程式設計計算1 1/2!-1/3! 1/4!-1/5!的值
6樓:
private sub command1_click()dim f as double
dim i as integer
dim sign as integer
f = 1
sign = 1
for i = 2 to 5
sign = -sign
f = f + sign * 1 / fac(i)next i
print "1+1/2!-1/3!+1/4!-1/5! ="; fend sub
function fac(n as integer) as longdim i as integer
fac = 1
for i = 2 to n
fac = fac * i
next
end function
高手請教,怎樣用vb編寫簡單的計算器?謝謝
加上一個按鈕 按鈕單擊事件內 dim a,b a 100 b 100 a b a b a b a b 明白了嗎?靠自己想想啦 直接給你原始碼 你寫不寫沒必要了就 自己慢慢連 增加知識 這個還是給你推薦本書吧 visual basic 程式設計 孫志輝編著。裡面有一章就是講簡單計算器的設計,如果能看到...
編寫求1到100之間奇數的和用vb語言
private sub command1 click dim i,sum1,sum2 as integersum1 0 sum2 0 for i 1 to 100 if i mod 2 1 then sum1 sum1 i else sum2 sum2 i end if next i print 奇...
vb計算下式的和變數與n的數值用輸入對話方塊輸入
階乘的計算還是用遞迴更高階一點 哈 vb程式設計題 計算下式的和,變數x與n的數值用輸入對話方塊輸入 s 1 x inclde int main printf 最後結果為 d s return 0 int pingfang a,b return result int jiecheng a retur...