VB編寫公式

2022-06-08 08:26:23 字數 1102 閱讀 4657

1樓:善護

si、ni 是什麼,我這裡使用簡單的函式 fs、fn 來表示,你可以修改這些函式,實現你需要的功能。

private function fs(byval i as long) as double

fs = i

end function

private function fn(byval i as long) as double

fn = i

end function

'實現 b = ……

public function fb(byval n as long) as double

dim i as long, s1 as double, s2 as double, s3 as double, s4 as double

dim vs as double, vn as double

s1 = 0: s2 = 0: s3 = 0: s4 = 0

for i = 1 to n

vs = log(fs(i)) / log(10)

vn = log(fn(i)) / log(10)

s1 = s1 + vs * vn

s2 = s2 + vs

s3 = s3 + vn

s4 = s4 + vs * vs

next

fb = (s1 - s2 * s3 / n) / (s3 - s2 ^ 2 / n)

end function

'實現 a = ……

public function fa(byval n as long) as double

dim i as long, s1 as double, s2 as double

s1 = 0: s2 = 0

for i = 1 to n

s1 = s1 + log(fn(i)) / log(10)

s2 = s2 + log(fs(i)) / log(10)

next

fa = s1 / n - fb(n) * s2 / n

end function

2樓:匿名使用者

si,ni分別是什麼呢?

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程式,求1編寫一個vb程式,求11213141n的值。測試資料n50答案

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 su...

用vb編寫1 3 599的問題,用VB迴圈結構怎麼求1 3

因為你是從1到99奇數相加,所以i 1 to 99 step 2。command click 名字錯了,少了一個1,應command1 click private sub command1 click dim i,sum sum 0 for i 1 to 99 step 2sum sum i nex...