VB程式設計裡的題目,求詳細程式設計。謝謝了

2021-05-02 11:22:18 字數 2283 閱讀 8385

1樓:

public function itotal(byval n as integer) as double

dim i as integer,n as integerdim itol as double, inum as double, ix as integer

inum = 0.3

for i = 1 to n

inum = inum + 3 * 10^(i-1)    'inum = 3.3+30+300+3000+...

ix = (-1)^(i-1)    'ix表示正負號itol = itol + ix * inumnext

itotal = itol

end function

sub 呼叫函式()

msgbox itotal(5)

end sub

2樓:岔路程式緣

你只要在視窗中放一個frame,再在frame中放兩個label1和label2。再在frame外面放一個label3,一個command1,一個text1。其他由程式完成,程式如下:

private sub command1_click()

dim sum as string

dim n as integer

dim i as integer, j as integer, k as integer

dim s as integer

n = val(text1)

for i = 1 to n

if i = 1 and (n mod 2 = 0) then k = -1 else k = 1

s = 0

for j = 1 to i

s = s + k

k = -k

next

sum = sum & s

next

if right(sum, 1) = "1" then sum = sum & ".1"

for i = 1 to len(sum)

if mid(sum, i, 1) = "1" then mid(sum, i, 1) = "3"

next

label2.caption = sum

end sub

private sub form_load()

with form1

.caption = "求和計算"

.width = 7000

.height = 4000

end with

with frame1

.caption = "求數列前n項和"

.width = 6000

.height = 1000

.top = 500

.left = 500

end with

with label1

.width = 2500

.height = 500

.caption = "3.3-33.3+333.3-3333.3+...="

.top = 400

.left = 100

end with

with label2

.width = frame1.width - (label1.left + label1.width) - 100

.height = label1.height

.caption = ""

.top = 400

.left = label1.left + label1.width

end with

with text1

.width = 1000

.height = 300

.text = ""

.top = 2500

.left = 4000

end with

with command1

.caption = "計算"

.width = 1000

.height = 300

.top = 2500

.left = 1000

end with

with label3

.width = 2000

.height = label1.height

.caption = "輸入n的值,n="

.top = command1.top

.left = command1.left + command1.width + 500

end with

end sub

已經執行過。

VB程式設計題目,vb程式設計題目

private sub mand1 click dim i as integer,j as integer,k as integer dim a 1 to 10 as integerdim max as integer,min as integer,pj as single dim sumnum a...

VB程式設計題目講解,vb程式設計題目

a 1在這段 裡面應該是代表了查詢到的匹配字串的位置text3.selstart a 1就是在text3中選中該匹配的字串的起始位置text3.sellength len text2.text 設定text3中選中字串的長度text3.seltext text2.text 就是把text2.text...

vb程式設計題求大神解答,VB程式設計軟體題目,求大神解答謝謝

private sub mand1 click if val text1.text 7 or val text1.text 1 then msgbox 有效數字輸入範圍1 7 exit sub end if text2.text choose val text1.text 一 二 三 四 五 六 日...