求助VB高手 急哦高分懸賞

時間 2021-09-21 02:55:42

1樓:岔路程式緣

第一題'建立一個text1,

dim r as single

dim s(8) as integer

private sub form_load()

form1.autoredraw = true

text1.text = 578.62

form1.width = 11000

text1.top = 1000

end sub

private sub text1_keypress(keyascii as integer)

select case keyascii

case 46, 48 to 57

case 13

if text1.text = "" then exit sub

r = format(val(text1.text), "0.00")

call zh(r)

print "一百元", "五十元", "十元", "五元", "一元", "五角", "一角", "五分", "一分"

for i = 0 to 8

print s(i),

next

case else

keyascii = ""

end select

end sub

function zh(byval i as single)

i = i * 100

s(0) = i \ 10000

i = i mod 10000

s(1) = i \ 5000

i = i mod 5000

s(2) = i \ 1000

i = i mod 1000

s(3) = i \ 500

i = i mod 500

s(4) = i \ 100

i = i mod 100

s(5) = i \ 50

i = i mod 50

s(6) = i \ 10

i = i mod 10

s(7) = i \ 5

s(8) = i mod 5

end function

第三題'建立七個command1-7

option explicit

dim str as string

dim s() as single, s1() as single, min as single, max as single

dim n as integer, i as integer, k as integer

dim shu as boolean

private sub command1_click()

clsstr = inputbox("陣列元素個數", "輸入", 10)

if str = "" then exit sub

if val(str) < 1 then exit sub

n = int(val(str)) - 1

redim s(n)

call sjsz

for i = 0 to n

print s(i);

if i mod 10 = 9 then print

next

print

command3.enabled = true

command4.enabled = true

command5.enabled = true

command6.enabled = true

end sub

private sub command2_click()

clsstr = inputbox("陣列元素個數", "輸入", 10)

if str = "" then exit sub

if val(str) < 1 then exit sub

n = int(val(str)) - 1

redim s(n)

for i = 0 to n

s(i) = srsz(i + 1)

print s(i);

if i mod 10 = 9 then print

next

print

command3.enabled = true

command4.enabled = true

command5.enabled = true

command6.enabled = true

end sub

private sub command3_click()

redim s1(n)

for i = 0 to n

s1(i) = s(i)

next

n = n + 1

redim s(n)

for i = 0 to n - 1

s(i) = s1(i)

next

s(n) = srsz(n + 1)

for i = 0 to n

print s(i);

if i mod 10 = 9 then print

next

print

end sub

private sub command4_click() '3)在陣列中第k個元素前插入一個元素;

str = inputbox("在第幾個元素前插入?(" & 1 & "-" & n + 1 & ")", "輸入", n)

if str = "" then exit sub

k = int(val(str))

if k < 1 or k > n + 1 then exit sub

redim s1(n)

for i = 0 to n

s1(i) = s(i)

next

n = n + 1

redim s(n)

s(k - 1) = srsz(k)

for i = 0 to n

if i < k - 1 then

s(i) = s1(i)

elseif i > k - 1 then

s(i) = s1(i - 1)

end if

next

for i = 0 to n

print s(i);

if i mod 10 = 9 then print

next

print

end sub

private sub command5_click() '4)刪除陣列中的第k個元素;

str = inputbox("刪除第幾個元素?(" & 1 & "-" & n + 1 & ")", "輸入", n)

if str = "" then exit sub

k = int(val(str))

if k < 1 or k > n + 1 then exit sub

redim s1(n)

for i = 0 to n

s1(i) = s(i)

next

n = n - 1

redim s(n)

for i = 0 to n

if i < k - 1 then

s(i) = s1(i)

elseif i >= k - 1 then

s(i) = s1(i + 1)

end if

next

for i = 0 to n

print s(i);

if i mod 10 = 9 then print

next

print

end sub

private sub command6_click()

str = inputbox("刪除哪個元素?", "輸入", n)

if str = "" then exit sub

min = val(str)

domax = cxys(min)

if max <> n + 2 then

msgbox "刪除第" & max + 1 & "個元素"

redim s1(n)

for i = 0 to n

s1(i) = s(i)

next

n = n - 1

redim s(n)

for i = 0 to n

if i < max then

s(i) = s1(i)

elseif i >= k then

s(i) = s1(i + 1)

end if

next

for i = 0 to n

print s(i);

if i mod 10 = 9 then print

next

print

end if

loop while max <> n + 2

end sub

private sub command7_click()

endend sub

private sub form_load()

form1.autoredraw = true

form1.width = 8000

form1.height = 6000

command1.caption = "產生隨機陣列"

command2.caption = "輸入陣列"

command3.caption = "後面新增"

command4.caption = "中間新增"

command5.caption = "按位置刪除"

command6.caption = "按值刪除"

command7.caption = "退出"

command3.enabled = false

command4.enabled = false

command5.enabled = false

command6.enabled = false

end sub

function srsz(byval l as integer) as single

dostr = inputbox("第" & l & "個元素", "輸入", l)

if str = "" then

shu = false

else

shu = true

srsz = val(str)

end if

loop while not shu

end function

private sub sjsz()

str = inputbox("陣列元素最小值數", "輸入", -100)

if str = "" then exit sub

min = int(val(str))

str = inputbox("陣列元素最大值數", "輸入", 100)

if str = "" then exit sub

max = int(val(str))

if max < min then exit sub

randomize

for i = 0 to n

s(i) = int(rnd * (max - min)) + min

next

end sub

function cxys(byval l as single) as integer '檢索要刪除的元素

for i = 0 to n

if s(i) = l then

cxys = i

exit for

else

cxys = n + 2

end if

next

end function

都執行過。

高分懸賞請高手為我算命,急!!!高分懸賞!!! 請高手幫我翻譯幾段英文!!!

年輕人,送你一句話 一個人的性格改變一個人的命運。就好像 裡的丁力和許 這麼說,通俗些,也易懂。如果你都到求別人算自己命的地步了,那麼你的這一生也差不多完了。機會把握在自己的手裡。抓不抓得住,在於你,而不是別人。不想和你費太多時間,祝你好運。 別信這個!成事在天,謀事在人!事在人為!知道麼?我也是1...

高分懸賞醫學高手請進,高分懸賞,急問網路問題,高手請進!

我姐姐以前一到夏天小腿上就出紅疹,非常癢,但是夏天過後自然就好了。中西醫都試過,沒有效果。後來我母親偶然和一個鄰居老太太說起此事,老太太說很簡單,只需要毛巾熱敷就可以,水最好熱一些,以 能夠承受為限度。每天上下午各敷一次,每次15分鐘就可以了。姐姐後來按照此法,很快就 了,至今7 8年過去再也沒有 ...

急高分懸賞,急 高分懸賞

剛典長清芬 要是你還工作的話,先找山西同意接受,然後去河北辦轉出手續,然後回山西辦理 急!高分懸賞 孤 心寒 把自己的心寄託在綠洲 乾璽繪美 為了無告的大自然 人類千百年來與大自然的抗爭推動了社會和經濟的巨大發展,但無需諱言也存在不少敗筆,給後代留下了難以治理的苦果。曾經的大澤湯湯,水草豐美 而今歷...