1樓:匿名使用者
private sub command1_click()dim a(1 to 5, 1 to 5)
text1.text = ""for i = 1 to ubound(a, 1)
for j = 1 to ubound(a, 2)randomize
a(i, j) = int(10 * rnd)text1.text = text1.text & str(a(i, j))
next j
text1.text = text1.text & vbcrlfnext iend sub
2樓:匿名使用者
**抄襲sub trygo()
dim a(4, 4) as integer, str as string
dim i as integer, j as integerfor i = 0 to 4
for j = 0 to 4
a(i, j) = int(10 * rnd)str = str & a(i, j) & " "
next j
str = str & vbcr
next i
debug.print str
end sub
輸出bai成du
果zhi
dao4 4 6 1 4
5 8 5 4 5
2 6 4 6 8
3 3 2 1 5
2 5 3 8 4
生成一個(0,10)之間的隨機整數構成的5行5列的矩陣,要求: (1)計算該矩陣的主、副對角線之和,並輸出
3樓:匿名使用者
private sub command1_click()dim temp%, s1&, s2&, s3&: clsfor i = 1 to 5
for j = 1 to 5
temp = int(rnd * 10)
if i = j then s1 = s1 + tempif i = 6 - j then s2 = s2 + tempif i = 1 or j = 1 or i = 5 or j = 5 then s3 = s3 + temp
print temp & " ";
next
next
print "主對角線和:" & s1
print "副對角線和
:" & s2
print "四周邊
專界屬和:" & s3
end sub
vb中利用隨機函式產生25個100到999之間的整數,構成5*5矩陣,輸出該矩陣,很急,謝謝
4樓:萍水e相逢
和bai 1 樓不一
du樣,
zhi我dao用到版
了權 text框
private sub command1_click()dim a(1 to 25) as integerdim i as integer
text1.text = ""
for i = 1 to 25
randomize
a(i) = int(900 * rnd + 100)text1.text = text1.text + cstr(a(i))
if i mod 5 = 0 then
text1.text = text1.text + vbcrlfelse
text1.text = text1.text + vbtabend if
next i
end sub
5樓:
private sub command4_click()dim a(24) as integer
call getrandomnumber(a)call printnumber(a)
end sub
private sub getrandomnumber(byref r() as integer)
randomize
dim i as integer
for i = 0 to 24
r(i) = int(900 * rnd()) + 100next i
end sub
private sub printnumber(byref r() as integer)
dim s as string
dim i as integer
dim j as integer
for i = 0 to 4
s = ""
for j = 0 to 4
s = s & vbtab & r(i * 5 + j)next j
debug.print s
next i
end sub
6樓:匿名使用者
private sub form_click()dim a(24), i, k as integerrandomize
for i = 0 to 24
a(i) = int(900 * rnd + 100)next i
for i = 1 to 25
print a(i - 1),
k = k + 1
if k mod 5 = 0 then print chr(13) & chr(10)
next i
end sub
vb程式設計題: 隨機生成一個4行9列的矩陣,矩陣元素為10-99之間的隨機整數.列印顯示.
7樓:山舟
option base 1
private sub form_click()dim a(36) as integer, b(6, 6) as integer, i as integer, j as integer, num as integer
print "原矩陣:"
randomize
for i = 1 to 36
a(i) = int((99 - 10 + 1) * rnd + 10)
print a(i);
num = num + 1
if num mod 9 = 0 then printnext
for i = 1 to 35
for j = 1 to 36 - i
if a(j) > a(j + 1) thent = a(j)
a(j) = a(j + 1)
a(j + 1) = t
end if
next
next
print "排序後矩陣:"
for i = 1 to 36
print a(i);
num = num + 1
if num mod 6 = 0 then printnext
print "主對角線上數字為:"
for i = 1 to 6
print a((i - 1) * 6 + i);
next
end sub
vb高手進,VB高手進啊
for就是重複執行。先看簡單的 fori 1to5 print ok i next ii 1 輸出。i 2也輸出.i 5輸出。i 6就沒有了。所以會輸出5個ok vb執行顯示是ok1 ok2ok3 ok4ok5 next i的左右就是 for.next 之間做重複的範圍 在生活有很多例子 如你再算1...
VB高手進啊
支援.一旦你學會了vb那麼學其他的絕對容易 但是如果你先學c,就會發現,c簡直是天書,等你學會了,黃瓜菜都涼了總體來說,先學vb再學c比先學c再學vb花的時間少得多 你先學qb吧 沒必要學vb 我現在把vb學精了,也就編寫一些遊戲 qb和許多語言是共通的,信我沒錯!學習vb首先要熟悉你所依賴的開發平...
使用vb進行程式設計有哪些步驟使用VB進行程式設計有哪些步驟
視覺化程式設計一般有一下步驟 設計程式介面 編寫程式 除錯 執行程式 物件導向的程式設計以物件為中心,以事件為過程執行的起點 例題 設計一個簡易的打字測試程式,單擊 開始 按鈕,計時開始,輸入字元 單擊 結束 按鈕,程式輸出打字速度。1 啟動vb,新建一個vb標準exe工程。單擊工具箱中的文字框控制...