By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,239 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,239 IT Pros & Developers. It's quick & easy.

sort 2d bar chart in ascending or descending order in ms chart

P: 1
very urgent help me
i am begginer in vb6 .vb have a default code to sort pie chart in ascending or desecending order in mschart like
(mschart.plot.sort=(0 or 1 or 2)

i want the code to sort other charts in mschart for 2d,3d bar,2d,3d step,2d,3d line

eg: this is the code


Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_Click()
  2. MSChart1.chartType = Combo1.ListIndex
  3. End Sub
  4. Private Sub Command1_Click()
  5. Dim X(1 To 10) As Integer
  6. If Val(Text1.Text) <= 1 Then
  7. MSChart1.Plot.SeriesCollection(1).Position.Excluded = True
  8. Else
  9. MSChart1.Plot.SeriesCollection(1).Position.Excluded = False
  10. X(1) = Val(Text1.Text)
  11. End If
  12. If Val(Text2.Text) <= 1 Then
  13. MSChart1.Plot.SeriesCollection(2).Position.Excluded = True
  14. Else
  15. MSChart1.Plot.SeriesCollection(2).Position.Excluded = False
  16. X(2) = Val(Text2.Text)
  17. End If
  18. If Val(Text3.Text) <= 1 Then
  19. MSChart1.Plot.SeriesCollection(3).Position.Excluded = True
  20. Else
  21. MSChart1.Plot.SeriesCollection(3).Position.Excluded = False
  22. X(3) = Val(Text3.Text)
  23. End If
  24. If Val(Text4.Text) <= 1 Then
  25. MSChart1.Plot.SeriesCollection(4).Position.Excluded = True
  26. Else
  27. MSChart1.Plot.SeriesCollection(4).Position.Excluded = False
  28. X(4) = Val(Text4.Text)
  29. End If
  30. If Val(Text5.Text) <= 1 Then
  31. MSChart1.Plot.SeriesCollection(5).Position.Excluded = True
  32. Else
  33. MSChart1.Plot.SeriesCollection(5).Position.Excluded = False
  34. X(5) = Val(Text5.Text)
  35. End If
  36. If Val(Text6.Text) <= 1 Then
  37. MSChart1.Plot.SeriesCollection(6).Position.Excluded = True
  38. Else
  39. MSChart1.Plot.SeriesCollection(6).Position.Excluded = False
  40. X(6) = Val(Text6.Text)
  41. End If
  42. If Val(Text7.Text) <= 1 Then
  43. MSChart1.Plot.SeriesCollection(7).Position.Excluded = True
  44. Else
  45. MSChart1.Plot.SeriesCollection(7).Position.Excluded = False
  46. X(7) = Val(Text7.Text)
  47. End If
  48. If Val(Text8.Text) <= 1 Then
  49. MSChart1.Plot.SeriesCollection(8).Position.Excluded = True
  50. Else
  51. MSChart1.Plot.SeriesCollection(8).Position.Excluded = False
  52. X(8) = Val(Text8.Text)
  53. End If
  54. If Val(Text9.Text) <= 1 Then
  55. MSChart1.Plot.SeriesCollection(9).Position.Excluded = True
  56. Else
  57. MSChart1.Plot.SeriesCollection(9).Position.Excluded = False
  58. X(9) = Val(Text9.Text)
  59. End If
  60. If Val(Text10.Text) <= 1 Then
  61. MSChart1.Plot.SeriesCollection(10).Position.Excluded = True
  62. Else
  63. MSChart1.Plot.SeriesCollection(10).Position.Excluded = False
  64. X(10) = Val(Text10.Text)
  65. End If
  66. X(1) = Val(Text1.Text)
  67. X(2) = Val(Text2.Text)
  68. X(3) = Val(Text3.Text)
  69. X(4) = Val(Text4.Text)
  70. X(5) = Val(Text5.Text)
  71. X(6) = Val(Text6.Text)
  72. X(7) = Val(Text7.Text)
  73. X(8) = Val(Text8.Text)
  74. X(9) = Val(Text9.Text)
  75. X(10) = Val(Text10.Text)
  76. MSChart1.ChartData = X
  77. MSChart1.chartType = VtChChartType2dPie
  78. MSChart1.Plot.Sort = VtSortTypeNone
  79. End Sub
  80.  
  81. Private Sub ascend_Click()
  82. MSChart1.Plot.Sort = VtSortTypeAscending
  83. End Sub
  84.  
  85. Private Sub descend_Click()
  86. MSChart1.Plot.Sort = VtSortTypeDescending
  87. End Sub
  88.  
  89. Private Sub exit_Click()
  90. Form1.Hide
  91. End Sub
  92.  
  93. Private Sub Form_Load()
  94. Dim X(1 To 10) As Integer
  95. With Combo1
  96. .AddItem "2D Step"
  97. .AddItem "3D Step"
  98. .AddItem "2D Line"
  99. .AddItem "3D Line"
  100. .AddItem "2D Area"
  101. .AddItem "3D Area"
  102. .AddItem "2D Combination"
  103. .AddItem "3D Combination"
  104. .AddItem "2D Bar"
  105. .AddItem "3D Bar"
  106. MSChart1.ChartData = X
  107. MSChart1.ColumnCount = 10
  108. MSChart1.RowCount = 1
  109. End With
  110.  
  111. With MSChart1.Legend
  112.   .Location.Visible = True
  113.   .VtFont.Name = "Arial"
  114.   .VtFont.Size = 8
  115.   .Location.LocationType = VtChLocationTypeTop
  116. End With
  117. End Sub
Jan 20 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.