Solved

VB5 Graphing

Posted on 1997-07-07
7
400 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
Comment Utility
Edited text of question
0
 
LVL 3

Accepted Solution

by:
ESI earned 100 total points
Comment Utility
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
Comment Utility
Thanks!  I'll try it and get back to you.  --  Norm
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:normpos
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

772 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

15 Experts available now in Live!

Get 1:1 Help Now