|
There will be no support provided for this page (But the download is free) The Other MS Graphing Tool For VB6 (Lesson 1) One Alternative On The Toolbar, select the
Before you get to carried away with programming the object, there are very important tests that you need to make.
The important point to remember is that the OLE objects need to be pre-installed on the computers where you want to run the software. The object packager does not add the MS Graph or MS Excel chart objects to the install kits. This solution is more suited in Intranets or Small Work groups where you have good control over you environment. You are now ready to start programming the object. For More Help Search VB 6 Help For Programming with Active X Components
Getting Data Into Your Graph Object Lesson 2 The easiest way to get data into the graph object is to use the import file option that come with MS Graph. Simply compile and run the VB project. You will end up with a form that looks like this. Apart from adding the MS Graph object, add a text field like the Double Click To Start Field that I have added. Double click on the graph to start it up. Select Menu Edit ... Import File
There are a one or two standard MS file import steps in between but the graph now looks as follows. So in summing up, you now have a small program for charting that required no programming and no need to train some how to use a spreadsheet. I will expand on how you can start programming data imports in the next lesson.
Alternative Import Method - Cut and Paste 1) Select the table of data in an alternative program such as an Access query. Copy the data using the clipboard. 2) Switch to the graph program that you have just created . 3) Right-click the chart and choose open. 4) If necessary, select the 'View' menu and select
'Datasheet' to view the datasheet. 5) Select the cell in the datasheet where the copied data is to be placed. 6) Select the 'Edit' menu and select 'Paste'.
Getting Data Into Your Graph Object Lesson 3 Now we come to the section where we need to add our own data in a programmatic fashion to the object. I thought this was going to be an easy one but No No No. The usual wild search through MSDN etc and finally I came up with something that showed me how to add data. For this example, add a new button to the graph which I have called cmdAddData Now add the following code to the Form_Load event.
Now you are going to build a string that allows you to transfer the data to the object. How you get this data in the first place is not part of this lesson but the datatext method initiates the transfer.
Other options worth looking into would be using arrays, the flex-grid control and automating transfers from text files. Switching The Standard Data Format As it is highly likely that you will be transferring your data from a recordset, you will need to change the project setup from the standard Series in rows to Series in Columns. To do this, Edit the graph object and select the Data menu as in the screen shot below.
Changing The Way MS Graph Looks Lesson 4 In this lesson, I will show you some of the visual basic code required to manipulate MSgraph The following picture shows some of the properties that you can manipulate in the Chart OLE object. First we will look at a declaration that I made in the Form_Load event to make referencing easier
To add a text string to the title of the graph, I have added a button at the bottom of the form.
To change the styles of the graph, try the following to change the form to Cylinders as above or maybe stacked 3D bars.
Some of the other constants that you can use for the graph are show in the table below
To toggle the graphs legend on and off, try the following
And to complete the lesson off, I have added horisontal and vertical slider bars to the form so that you can rotate and tilt 3D Graphs. The code for the horizontal rotation is as follows
Printing the MSGraph Form Lesson 5 We are finally getting to the point where the graph form is starting to be useful. But we need to print it out. To the form I have now added added a print button with the following code. The important method here is PrintForm. This will only be suitable if the form is not cluttered with other objects as printform literally prints the form AS IS.
The little trick that I used here was to hide all the objects in the form that do not have a tag property of Print. When the form has been printed, turn them all back on again with the same form. Add the Tag property manually by opening each object that should be printed and typing in Print in the tag field.
That's it for controlling the MS Graph Object from Visual Basic 6. Hope you gained something useful from it !!! Garry Robinson
|
|
Links >>> Home | Search | Workbench | Orders | Newsletter | Access Security | Access professionals |