1樓:匿名使用者
private sub ***mand1_click()print "第3題:";
dim n as integer, s as doublen = inputbox("n=", , 50)for i = 1 to n
s = s + 1 / i
next i
print "sum(" & n & ")="; format(s, "0.00")
end sub
private sub ***mand2_click()print "第4題:";
dim n as integer, s as doublen = inputbox("n=", , 50)for i = 1 to n
s = s + (-1) ^ (i - 1) * (1 / i)next i
print "sum(" & n & ")="; format(s, "0.00")
end sub
private sub ***mand3_click()print "第5題:";
dim n as integer, s as doublen = inputbox("n=", , 20)for i = 1 to n
for j = 1 to i
s = s + j
next j
next i
print "sum(" & n & ")="; send sub
private sub ***mand4_click()print "第6題:";
dim n as integer, s as doublen = inputbox("n=", , 50)for i = 1 to n
if i mod 3 = 0 or i mod 7 = 0 thens = s + i
end if
next i
print "sum(" & n & ")="; send sub
private sub ***mand5_click()print "第7題:";
dim n as integer, s as doublen = inputbox("n=", , 10)s = 1
for i = 1 to n
s = s * i
next i
print n & "!="; s
end sub
2樓:
^^private sub form_click()dim i as integer
dim x as single
for i = 1 to 50
x = x + 1 / i
next
print x
end sub
private sub form_click()dim i as integer
dim x as single
for i = 1 to 50
x = x + (-1) ^ (i - 1) / inext
print x
end sub
函式遞迴
private sub form_click()print f(50)
end sub
public function f(x as integer) as single
if x > 1 then
f = f(x - 1) + (-1) ^ (x + 1) / xelse
f = 1
end if
end function
vb程式設計計算1+1/2!+1/3!+1/4!+1/5!的值
3樓:哪呢
private sub ***mand1_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
4樓:會飛滴包子
private sub ***mand1_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編寫一個鬧鐘程式
做一個簡單的鬧鐘程式很簡單的。我這裡不用if語句。首先我們在窗體上新增一個標籤控制元件,再畫一個 鬧鐘 將鬧鐘得interval屬性改為1000,雙擊鬧鐘,進入鬧鐘的 檢視,編寫 private subtimer1 timer timeend sub就行了。謝謝。dimttime s asinteg...
vb編寫程式計算分段函式,VB編寫程式,計算分段函式
在窗體上放一個命令按鈕,將 複製到窗體裡,程式執行單擊一次命令按鈕可輸入一次n的值 如下 private sub command1 click dim n,y as single n inputbox 請輸入n的值 select case n case is 0 y 2 n 5 case 0 y 0...
編寫VB程式,求Sn a aa aaan個a 的值,其中n是表示a的個數,a是
dim sn,a,n,i,m m 0sn 0 a int rnd 10 n text1.text for i 1 to n m 10 i 1 a m sn sn m next i 應該就是這樣了,有點久沒用vb,有點忘了 private sub form click dim sn a int rnd...