fork download
  1. Sub sort(x(), y(), n)
  2. For i = 0 To n - 1
  3. For j = 1 To n - i
  4. If x(j - 1) > x(j) Then
  5. t = x(j - 1)
  6. x(j - 1) = x(j)
  7. x(j) = t
  8. t = y(j - 1)
  9. y(j - 1) = y(j)
  10. y(j) = t
  11. End If
  12. Next j
  13. Next i
  14. End Sub
  15.  
  16. Sub test_plot()
  17.  
  18. '適当なデータを用意
  19. Dim x1(5), y1(5)
  20. Dim x2(14), y2(14)
  21.  
  22. For i = 0 To 5
  23. x1(i) = Rnd
  24. y1(i) = x1(i) * x1(i)
  25. Next i
  26. Call sort(x1, y1, 5)
  27.  
  28. For i = 0 To 14
  29. x2(i) = Rnd
  30. y2(i) = x2(i) + x2(i)
  31. Next i
  32. Call sort(x2, y2, 14)
  33.  
  34. '確認のためにセルに書き込み
  35. [A1] = "x1"
  36. [B1] = "y1"
  37. For i = 0 To 5
  38. Cells(2 + i, 1) = x1(i)
  39. Cells(2 + i, 2) = y1(i)
  40. Next i
  41.  
  42. [C1] = "x2"
  43. [D1] = "y2"
  44. For i = 0 To 14
  45. Cells(2 + i, 3) = x2(i)
  46. Cells(2 + i, 4) = y2(i)
  47. Next i
  48.  
  49. 'グラフ描画
  50. Dim ch As ChartObject
  51. Set ch = ActiveSheet.ChartObjects.Add(300, 10, 300, 200)
  52.  
  53. With ch.chart
  54. 'With .Axes(xlCategory, xlPrimary)
  55. ' .MinimumScale = 0
  56. ' .MaximumScale = 1
  57. 'End With
  58.  
  59. With .SeriesCollection.NewSeries
  60. .ChartType = xlLine
  61. .AxisGroup = 1
  62. .XValues = x1
  63. .Values = y1
  64. End With
  65.  
  66. With .SeriesCollection.NewSeries
  67. .ChartType = xlLine
  68. .AxisGroup = 2
  69. .XValues = x2
  70. .Values = y2
  71. End With
  72.  
  73. End With
  74.  
  75. End Sub
  76.  
  77.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty