看板 Visual_Basic 關於我們 聯絡資訊
今天我用一個intputbox彈出一個視窗來讓使用者選取一個方陣範圍 ex:2*2,3*3,4*4 set matrix = Application.IntputBox(prompt:="選取矩陣", Title:="matrix", type:=8) Dim row,column as Integer row=matrix.Row.Count column=matrix.Row.Count 那接下來我有一個二維陣列 dim a() reDim a(row-1,column-1) 要怎麼把選取範圍的值指定到陣列內? 就是讓a(0,0)=matrix(0,0) a(0,1)=matrix=(0,1)...以此類推 我寫成 for i= 0 to row-1 for j= 0 to column-1 a(i, j)=matrix.Cells(i,j).Value 這樣好像會有問題 請問要怎麼把一個範圍的值指定到二維陣列內呢? 感激不盡 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 101.11.18.15 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1571988330.A.444.html
newacc: 印象中直接a=matrix就可以了? 10/26 19:06
newacc: 另一個是Cells的第一項應該是1,所以可能是Cells(0,0)出 10/26 19:07
newacc: 問題 10/26 19:07
hellk: a=matrix.param matrix一定要二維 01/05 20:13