1樓:匿名使用者
dim a(), b(), c(), i as integerprivate sub command1_click()for i = 0 to 4
print a(i);
next
end sub
private sub command2_click()for i = 0 to 4
print b(i);
next
end sub
private sub command3_click()for i = 0 to 4
print c(i);
next
end sub
private sub form_load()a = array(1, 2, 3, 4, 5)b = array(6, 7, 8, 9, 10)c = array(0, 0, 0, 0, 0)end sub
2樓:聽不清啊
dim a(10) as integer
private sub command1_click()for i = 1 to 5
print a(i);
next i
end sub
private sub command2_click()for i = 6 to 10
print a(i);
next i
end sub
private sub command3_click()for i = 1 to 5
print 0;
next i
end sub
private sub form_load()for i = 1 to 10
a(i) = i
next i
end sub
vb的陣列應用,請高手看看哪錯了!很簡單的一個小例子!!
3樓:沙慧月
s2 = s2 & " " & str(a(i))這句在陣列b裡,所以改為s2 = s2 & " " & str(b(i))
dim text as integer 這句提到通用裡,不然command2無法得到text值
正確**為:
dim a() as integer '在這宣告瞭陣列
dim b() as integer
dim text as integer
private sub command1_click()
dim s1, s2 as string
text = val(form1.text1.text)
if text > 9 then
msgbox "請輸入九個以下的陣列元素個數!"
exit sub
end if
randomize '初始化隨機數生成器
'以下是陣列a
redim a(text) as integer '在這宣告瞭一個陣列
for i = 0 to (text - 1) '開始為陣列中的元素賦值
a(i) = int(rnd * 100) '隨機生成0 - 99的整數
s1 = s1 & " " & str(a(i))
next
form1.text2.text = s1
randomize '初始化隨機數生成器
'以下是陣列b
redim b(text) as integer
for i = 0 to (text - 1) '開始為陣列中的元素賦值
b(i) = int(rnd * 100) '隨機生成0 - 99的整數
s2 = s2 & " " & str(b(i))
next
form1.text3.text = s2
end sub
private sub command2_click()
dim s as string
'以下是陣列c
redim c(text) as integer
for i = 0 to (text - 1)
c(i) = a(i) + b(i)
s = s & " " & str(c(i))
next
form1.text4.text = s '顯示陣列c
end sub
VB初學者的小問題
完整程式應該是 option explicit dim a as integer dim b as integer private sub command1 click a val text1.text b val text2.text label2.caption a bend sub priva...
求解VB程式設計題(初學者),請教一道VB陣列程式設計題(大學初學者),謝謝!!!
恕我直言,要查錯遠遠比解題麻煩多了.所以,如果可以,請把題目補充出來,晚一點我再看回來.祝好運.我也貼一段 function ishuiwen n as double as boolean 判斷是否迴文數 ishuiwen false dim m,i as double m 0 i n while ...
吉他初學者求簡單好學的吉他彈唱譜
可以先進行單音的練習。建議練習彈奏 小星星 愛的羅曼斯 歡樂頌 等回。練習簡單的和答 弦。建議 紅河谷 送別 你知道我在等你嗎 等。再慢慢練習難一點的和絃,要熟練。這就可以根據自己的喜好來選擇歌曲了。練習掃弦。從簡單到熟練。建議 老男孩 等。beyond樂隊 真bai的愛你 汪 du峰 春天裡 怒放...