Solved

Adding MSChart control dymanically in vb

Posted on 2004-08-18
8
2,824 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 70

Expert Comment

by:Éric Moreau
ID: 11832348
0
 

Author Comment

by:csbhatt1
ID: 11838032

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 70

Expert Comment

by:Éric Moreau
ID: 11841835
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

Author Comment

by:csbhatt1
ID: 11849110
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
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 11869464
On which line? Can you show your code?
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 11944400
Still alive?
0
 

Author Comment

by:csbhatt1
ID: 11952857
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 70

Accepted Solution

by:
Éric Moreau earned 125 total points
ID: 11954142
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSumClump challenge 9 115
Please explain: Aspect Oriented Programming 2 92
Re-position the objects 7 108
Definitions and default visual studio colors 5 65
This article will show, step by step, how to integrate R code into a R Sweave document
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

813 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