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
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
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
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
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
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
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
都執行過。
vb程式設計高手進,高分求助
窗體 請到我的空間提取 msgbox 除數為零,請檢查輸入的資料是否正確!vbcritical vbokonly,輸入錯誤 end if end if end sub private sub mnuclear click text1.text text2.text text3.text label1...
求助電腦高手。(高分懸賞)
這麼簡單的問題 教你 個方法吧,把求生4裡面的 對比度調小一點就可以了。試下吧 比如 1800 你調到1050 左右就ok了。和你說啊 我不知道你極品13是畫面特效全開麼?我家裡的是ati hd4690 效能比9500gt顯示卡好我玩極品13 都沒法開全特效玩 有可能是你的特效沒全部開啟,所以不卡 ...
高分懸賞請高手為我算命,急!!!高分懸賞!!! 請高手幫我翻譯幾段英文!!!
年輕人,送你一句話 一個人的性格改變一個人的命運。就好像 裡的丁力和許 這麼說,通俗些,也易懂。如果你都到求別人算自己命的地步了,那麼你的這一生也差不多完了。機會把握在自己的手裡。抓不抓得住,在於你,而不是別人。不想和你費太多時間,祝你好運。 別信這個!成事在天,謀事在人!事在人為!知道麼?我也是1...