Solved

Adding MSChart control dymanically in vb

Posted on 2004-08-18
8
2,812 Views
Last Modified: 2013-11-13
Hi
How do I add MSChart control Dynamically in VB duiring run time

thanks

bhatt
0
Comment
Question by:csbhatt1
  • 5
  • 3
8 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 

Author Comment

by:csbhatt1
Comment Utility

I am adding mschart control in dynamic tab in a frame as

Call Controls.Add("VB.MSChart", "MSChart" & CStr(count), Controls("Frame1"))

but ivb is giving error as

"invalid class string"
looking for object with progid VB.MSChart

0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
The chart control is not an intrinsic control so you cannot use VB. It is also a licensed control.

Private Sub Command1_Click()
Dim objChrt As Object

    Licenses.Add "mschart20lib.MSChart"
    Set objChrt = Controls.Add("mschart20lib.MSChart", "MSChart1", Controls("Frame1"))
    With objChrt
        .Top = 120
        .Left = 120
        .Height = Frame1.Height - 240
        .Width = Frame1.Width - 240
        .Visible = True
    End With
End Sub

0
 

Author Comment

by:csbhatt1
Comment Utility
thanks  a lot

i got it

One more thing, whenever i try to update the chart data through some other event such as data arrival through winsock it is displaying following eror mesasge
runtime error 91
object variable or with block ariable not  set

regards

bhatt
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
On which line? Can you show your code?
0
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
Still alive?
0
 

Author Comment

by:csbhatt1
Comment Utility
hi
sorry for the delay i was out for some time

I am able to do it now

I created a dynamic chart using

following code
+++++++++++++++++++++++++++++++++++++++++++
Set mschart_xyz = Controls.Add("MSChart20Lib.MSChart", "mschart_xyz", Controls(sFrame))
        With mschart_xyz
            .Visible = False
            .Top = 450
            .Left = 7500
            .Width = 7000
            .Height = 4400
            .chartType = VtChChartType2dLine
            .DrawMode = VtChDrawModeDraw
            .Plot.Backdrop.frame.Style = VtFrameStyleThickInner
            .Plot.Backdrop.Shadow.Style = VtShadowStyleDrop
            .Plot.Axis(VtChAxisIdX).AxisGrid.MajorPen.VtColor.Set 150, 150, 150
            .Plot.Axis(VtChAxisIdX).Pen.Style = VtPenStyleDashDit
            .Plot.Axis(VtChAxisIdY).AxisGrid.MajorPen.VtColor.Set 150, 150, 150
            .AllowSelections = False
            .Legend.Location.Visible = False
            .Legend.Location.LocationType = VtChLocationTypeTop
           
           
           
     
    End With
+++++++++++++++++++++++++++++++++++++++++++

and on
Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
I update the chart using

Me.Controls("mschart_xyz").ChartData = bpsXY

earlier ther error was comming because i was trying it like this
"mschart_xyz.chartdata=bpsXY"
i dont know why???

here bpsXY is an array where i store the data which is comming other machine in network

But here i have a problem of flickering of the chart whenever it is updated. This  flickering is depending on the performance of the machine on high end machine this is negligeble
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 125 total points
Comment Utility
Why don't you just set the Visible property after you set all the properties and the data?

You can also try to lock the display with this API :
Private Declare Function LockWindowUpdate _
                Lib "user32" _
                (ByVal hwndLock As Long) As Long
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

Suggested Solutions

Title # Comments Views Activity
how to open Waze.com/livemap from address saved in DB? 26 151
matchUp  challenge 9 71
array220 challenge 8 44
count11 challenge 6 47
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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

13 Experts available now in Live!

Get 1:1 Help Now