In this post, there are description about Chart Design In VB6.0 with step by step process to provide special and advance features in chart with easy tech tips. Chart or Graph provide graphical description of data, where we display data with graphical presentation. In VB you need predefined tools or have to create a tools to describe the graphical presentation of data.
In Visual Basic 6.0, you will find a predefined chart control tools with name “Microsoft Chart Control 6.0(OLEDB)” . If you cannot find this component in Visual Basic, just download “MSChart20.ocx" for any website where this component available. And put this OCX file in “C\Windows\System32” path.
Where to find Chart Control in VB6.0?
For add this component in Visual Basic 6.0.
➤ First, you have to go to “Project” menu of your Application window. And find “Component” option and click on it.
➤ First, you have to go to “Project” menu of your Application window. And find “Component” option and click on it.
➤ Then a window will open, find “Microsoft Chart Control 6.0(OLEDB)” and check on it. Then press “Apply” and “OK” button.
Steps:
“Project”>> “Component”>> “Microsoft Chart Control 6.0(OLEDB)” (check it)
Add Control To ToolBox Process |
What types of Properties use for Chart Design?
Here, we will learn some properties of MSChart Control through “Properties” window or through code. There are some following properties instructions.
Menu design with properties setting in VB6.0 easy tech tips
(1) Change Chart Type Properties in VB6.0:
For this setting, you have to go to “Properties” window and find “ChartType” property. Select any option whatever you want.
Chart type properties settings |
You can change it through coding. Suppose, you want to change chart type through combo selection. Then you have to write code in Combo’s Change() event. There is following code process.
Private Sub Combo2_Change() Dim Chrttype As String Chrttype = Combo2.Text With MSChart1 Select Case Chrttype Case "2dArea" .chartType = VtChChartType2dArea Case "2dBar" .chartType = VtChChartType2dBar Case "2dCombination" .chartType = VtChChartType2dCombination Case "2dLine" .chartType = VtChChartType2dLine Case "2dPie" .chartType = VtChChartType2dPie Case "2dStep" .chartType = VtChChartType2dStep Case "2dXY" .chartType = VtChChartType2dXY Case "3dArea" .chartType = VtChChartType3dArea Case "3dBar" .chartType = VtChChartType3dBar Case "3dCombination" .chartType = VtChChartType3dCombination Case "3dLine" .chartType = VtChChartType3dLine Case "3dStep" .chartType = VtChChartType3dStep End Select End With End Sub
You have to write this code in Combo’s Click() event.
Crop photo from image in VB6.0 Easily
(2) Change Border Style with Shadow of Graph in VB6.0:
You can Change Graph’s border through MSChart’s Custom Property window.
➤ Just right click on MSChart1 and select “Properties” Option.
➤ This will show “Property Pages” screen. This screen contains multiple tabs.
➤ Go to “Backdrop” tab and select “Plot” option from “Property Name” combo. And apply settings whatever you want to change.
MSChart1 (Right Click)>> Properties >> Backdrop >> Plot
Chart's Plot setting |
If you want to change border style at run time, then you have to right code for it, Suppose, you want to change it through button press. Then write this code on command Click() event as mention bellow.
Border Style Code:
Private Sub Command2_Click() 'This will change border type MSChart1.Plot.Backdrop.Frame.Style = VtFrameStyleThickOuter 'This will change Border color MSChart1.Plot.Backdrop.Frame.FrameColor.Set 255, 100, 20 End Sub
Graph Shadow Code:
Private Sub Command1_Click() MSChart1.Plot.Backdrop.Shadow.Style = VtShadowStyleDrop End Sub
(3) Change Graph Color in VB6.0:
If you want to change Graph color according to your desire, then there is two processes, first is through property setting and second is through code.
Graph Color setting through Property:
Just go to Custom property page window and select “Series Color” Tab. Then apply C1, C2, C3, C4 etc. color settings.
Series Color settings |
After that you will see that this will change the color of your graph.
Suppose, you want to change color at run time, then write code inside command’s Click() event as mention bellow.
Private Sub Command4_Click() With MSChart1 'C1 Color change .Plot.SeriesCollection(1).DataPoints(-1).Brush.FillColor.Set 152, 50, 250 'C2 Color Change .Plot.SeriesCollection(2).DataPoints(-1).Brush.FillColor.Set 252, 50, 100 'C3 Color Change .Plot.SeriesCollection(3).DataPoints(-1).Brush.FillColor.Set 12, 250, 200 'C2 Color Change .Plot.SeriesCollection(4).DataPoints(-1).Brush.FillColor.Set 252, 150, 80 End With End Sub
(4) Change Graph Brush Style in Visual Basic 6:
Now, if you want to change brush style around graph, you have to write code for setting of it. Suppose, if you want to change through combo selection, then write code inside Combo’s Change() and Click() event. The code is describing bellow.
Private Sub Combo1_Change() With MSChart1 If Combo1.Text = "Null" Then .Plot.Wall.Brush.Style = VtBrushStyleNull End If If Combo1.Text = "Solid" Then .Plot.Wall.Brush.Style = VtBrushStyleSolid End If If Combo1.Text = "Pattern" Then .Plot.Wall.Brush.Style = VtBrushStylePattern End If If Combo1.Text = "Hatched" Then .Plot.Wall.Brush.Style = VtBrushStyleHatched End If End With End Sub
This code’s process is mention in following Gif.
So, there are some advance features of Graph Design in VB mention above by which you can easily learn Chart Design with Special Feature in Visual Basic 6.0 with SKOTechLearn.
MSHFlexGrid with database record in VB6.0 with tech tips
0 comments: