Solved

VB5 Graphing

Posted on 1997-07-07
7
404 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

863 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

Need Help in Real-Time?

Connect with top rated Experts

29 Experts available now in Live!

Get 1:1 Help Now