[VBA ] Excel 的 VBA使用氣泡排序法問題

看板Visual_Basic作者 (尖東Roger)時間18年前 (2008/04/10 00:09), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
不知道是不是在此發問 已在Excel中建立數據資料表 並要撰寫一巨集使用氣泡排序法重新排序 執行結果會跑出一視窗直接將結果輸出 程式碼如下: Public Sub 設標題() Cells(2, 1).Value = "原始資料" Cells(2, 2).Value = "A" Cells(2, 3).Value = "B" Cells(2, 4).Value = "C" Cells(2, 5).Value = "D" Cells(2, 6).Value = "E" Cells(2, 7).Value = "F" Cells(2, 8).Value = "G" Cells(2, 9).Value = "H" Cells(2, 10).Value = "I" Cells(2, 11).Value = "J" Cells(2, 12).Value = "K" Cells(2, 13).Value = "L" Cells(2, 14).Value = "M" Cells(2, 15).Value = "N" Cells(2, 16).Value = "O" End Sub _________________________________________ Public Sub 編號() For i = 4 To 16 Cells(i, 1).Value = i - 3 Next End Sub _________________________________________ Private Sub Command1_Click() Dim A(15) As Integer Dim TempVal As Integer [A = 93: B = 92: C = 88: D = 85: E = 76: F = 87: G = 85: H = 71: I = 73: J = 96: K = 74: L = 91: M = 82: N = 83: O = 95] TempVal = 0 Picture1.Print "陣列排序過程" For Loop1 = 1 To 14 For Loop2 = 1 To 15 - Loop1 If A(Loop2) > A(Loop2 + 1) Then TempVal = A(Loop2) A(Loop2) = A(Loop2 + 1) A(Loop2 + 1) = TempVal End If Next Picture1.Print "第" & Loop1 & "回" For loop3 = 1 To 15 Picture1.Print A(loop3) Next Picture1.Print Next End Sub 不過一直錯誤 不知哪裡出了問題 請大大幫解 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.135.64.161

04/10 02:01, , 1F
是怎樣錯?
04/10 02:01, 1F
文章代碼(AID): #17_Ef8tM (Visual_Basic)
文章代碼(AID): #17_Ef8tM (Visual_Basic)