VB5 Graphing

Posted on 1997-07-07
Last Modified: 2012-06-27
I have a large app written in VB3 which I am improving, and moving into VB5.  One place in the app draws a line graph in a Picture Box. The old app did this (tediously) by using .line, and such.  In my new VB5 version, I thought I would try MSChart, because it is prettier (and not so tedious).  Pages 79 and 80 of the Microsoft VB Component Tools Guide show how to do this, but the description is murky and poorly described.

I have a one-dimensioned integer array of data to be plotted
   Dim Gdata(1000) as Integer
It is only partly filled, up to index Gmax (an integer), which I know.  How do I import that into MSChart?  I would appreciate someone showing me how.

My best efforts get the graph axis, with the vertical scale auto-scaled ok (so MSChart is "seeing" the data properly), but the horizontal scale has no numbers, just "R1".  -- And no curve is drawn.

Please help -- Norm Pos  
Question by:normpos
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3

Author Comment

ID: 1428063
Edited text of question

Accepted Solution

ESI earned 100 total points
ID: 1428064
The easiest way is to set the .AutoIncrement property of the MSChart to True and give the successive values to the chart via its  .Data property
Don't forget to tell the chart how many rows will be displayed, via the RowCount property.
For example :

With MSChart1
    .AutoIncrement = True
    .RowCount = 20
    for I = 1 to 20
        .Data = m_array_of_values(i)
    next i
End With

That's all ! Hope it helped !

Author Comment

ID: 1428065
Thanks!  I'll try it and get back to you.  --  Norm
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.


Author Comment

ID: 1428066
esi:  OK!  It works!  One puzzling thing, would appreciate your comments:  The x-axis apparently does not self-scale (with numbers) like the y-axis.  The y (vertical) axis is fine, but the x-axis insists on labeling every plotted point with a "Rx" number.  I fiddled around with the "properties" dialog for MSChart1 with no results.  The properties for the x and y axis appear to be the same in the properties dialog, but they don't work the same for some reason.  I finally deleted the y-axis and wrote my own scaling marks, but that should not be necessary.

Under "insertable objects" (components, under project menu), there is something called "Microsoft Graph 5.0".  I tried that, and my screen went nuts, with all kinds of windows blinking back and forth.  I had to give it the three-finger-salute to stop it.  Then, when I tried to turn the computer off the usual way, (start - shutdown) I got a plain white message box saying "Graph 5.0 cannot be stopped".  What to do?  I simply turned off the computer.  Nothing was damaged, it turned back on and booted up ok.  So what's with this Graph 5.0 thing?  --  Norm

Expert Comment

ID: 1428067
I tried to use the Graph 5 OLE server (means you must include OLE objects handler in the controls of your project), but I gave up quickly for the reasons you mentionned above and seveal others too ;^(.
I figure out this graph control is used by the Office applications , but I prefered include the excellent Graph Server from Bits per Second shipped with VB (BPS Graph Control). It works via OLE too but works fine with much more properties and logarithmic Y scaling.
Well, hope it helped, and good luck !

Author Comment

ID: 1428068
Thank you.  I don't recall seeing a "BPS" grapher in my installation.  I'll take another look.  Meantime, if you have a third party graphing package you would recommend, I would be interested in your suggestions.  --  Norm

Expert Comment

ID: 1428069
Lock under "Pinnacle-BPS Graph Control" under the Ctrl-T components of VB, or if not install, click Browse and select the \Windows\System\GRAPH32.OCX , VB will then install it on your system.
Btw, my prefered is the VtChart Control from First Impression (the one shipped with Delphi 2), but it's not free if you need a commercrial (read redistribuable) licence.

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question