Here's a simple VB6 code snippet that uses the MSChart control to display Charts in VB6.0.
To use this sample, please following steps
Create a new project in VB6
Pull down the Project menu and choose Components .
Select the checkbox next to Microsoft ChartControl 6.0(OLEDB), Click OK.
Add a combobox,one Mschart control and one check box tothe existing form.
Paste in the following code tothe code window - Private Sub Form_Load()
-
'Fill the combo box with different types of chart types.
-
With Combo1
-
.AddItem "3D Bar"
-
.AddItem "2D Bar"
-
.AddItem "3D Line"
-
.AddItem "2D LIne"
-
.AddItem "3D Area"
-
.AddItem "2D Area"
-
.AddItem "3D Step"
-
.AddItem "2D Step"
-
.AddItem "3D Combination"
-
.AddItem "2D Combination"
-
End With
-
'Declare 2D array to store values for the chart
-
'Variant ----so that can store both text as well as numbers
-
Dim X(1 To 7, 1 To 6) As Variant
-
-
X(1, 2) = "Steel"
-
X(1, 3) = "Aluminium"
-
X(1, 4) = "Copper"
-
X(1, 5) = "Buxite"
-
X(1, 6) = "Lead"
-
-
X(2, 1) = "JAN"
-
X(2, 2) = 2
-
X(2, 3) = 3
-
X(2, 4) = 4
-
X(2, 5) = 5
-
X(2, 6) = 6
-
-
X(3, 1) = "FEB"
-
X(3, 2) = 4
-
X(3, 3) = 6
-
X(3, 4) = 3
-
X(3, 5) = 10
-
X(3, 6) = 18
-
-
X(4, 1) = "MAR"
-
X(4, 2) = 1
-
X(4, 3) = 3
-
X(4, 4) = 8
-
X(4, 5) = 7
-
X(4, 6) = 9
-
-
X(5, 1) = "APR"
-
X(5, 2) = 4
-
X(5, 3) = 6
-
X(5, 4) = 13
-
X(5, 5) = 10
-
X(5, 6) = 12
-
-
X(6, 1) = "MAY"
-
X(6, 2) = 2
-
X(6, 3) = 9
-
X(6, 4) = 9
-
X(6, 5) = 12
-
X(6, 6) = 7
-
-
X(7, 1) = "JUN"
-
X(7, 2) = 13
-
X(7, 3) = 20
-
X(7, 4) = 5
-
X(7, 5) = 18
-
X(7, 6) = 11
-
'2D array is the data for the chart control.
-
MSChart1.ChartData = X
-
'Default chart type is se to 2D bar chart.
-
MSChart1.chartType = 1
-
-
End Sub
-
-
Private Sub Check1_Click()
-
If Check1.Value = 1 Then
-
'Show Legends
-
MSChart1.ShowLegend = True
-
Check1.Caption = "&Hide Legends"
-
Else
-
'Hide Legends
-
MSChart1.ShowLegend = False
-
Check1.Caption = "&Show Legends"
-
End If
-
End Sub
-
-
Private Sub Combo1_Click()
-
'To change the chart type at run time.
-
MSChart1.chartType = Combo1.ListIndex
-
End Sub
NOTE:-The above sample code works for default name of controls ,code need to be modified accordly if the name of controls are different.
0 50812 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Job Lot |
last post by:
How can i dynamically add mschart control to my form. I am getting some
"Inavlid state" error.
thanx
|
by: Jon Henry |
last post by:
Hi,
I have a question regarding using the MSChart control in Visual C#
Standard 2003. I understand that you can add it to the Toolbox and use
it like any other control-- the problem I'm having...
|
by: Don Wash |
last post by:
Hi All!
I've been searching everywhere for a simple sample of producing a bar graph
using CrystalReport by specifying SQL Query, and I've found none of it! I
find so many complex samples with so...
|
by: Jeffrey Spoon |
last post by:
Hello, I'm trying to plot some data on a 2d line chart using MSChart.
The code below worked fine on a 2d bar chart, but nothing appeared when
using the 2dline chart property. Should I use the...
|
by: David Caissie |
last post by:
I am trying to automate a Vb.net chart using the excel COM object. The
problem occurs when trying to run the code in different systems. It is
working fine under one of my computers but once i move...
|
by: debasisdas |
last post by:
Hi i am using MSCHART control in VB6 to create some interactive chart.
It works fine ,but my problem is every time i frame the query dynamically as per user interaction it skips the first record...
|
by: shweta goel |
last post by:
Anyone can tell me : how to draw pie chart using MSChart control having data from 2 or 3 variables.
|
by: Arhan Demirali |
last post by:
Hello Everyone,
I am trying to create an Organizational Chart using C# to display on
the WEB. (web application)
I have a TABLE of data containing the information for who is the
supervisor of...
|
by: Mas Juliza Alias |
last post by:
I have a table (MSFlexgrid1) in a form (frmCalculate) containing 2 columns of Depth and Volume data. I want to draw a line graph of Depth Vs Volume in a new form (frmGraph) by using MSChart control....
|
by: MeoLessi9 |
last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: Aftab Ahmad |
last post by:
Hello Experts!
I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: marcoviolo |
last post by:
Dear all,
I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
| |