Solved

VB5 Graphing

Posted on 1997-07-07
7
416 Views
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  
0
Comment
Question by:normpos
  • 4
  • 3
7 Comments
 

Author Comment

by:normpos
ID: 1428063
Edited text of question
0
 
LVL 3

Accepted Solution

by:
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 !
0
 

Author Comment

by:normpos
ID: 1428065
Thanks!  I'll try it and get back to you.  --  Norm
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:normpos
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
0
 
LVL 3

Expert Comment

by:ESI
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 !
0
 

Author Comment

by:normpos
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
0
 
LVL 3

Expert Comment

by:ESI
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Updates not working for MS Windows 7 12 181
VB6 Compile Compatibility Issue 4 115
How to debug this code 7 64
fso.FolderExists("\\server\HiddenFolder$") 4 78
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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