Solved

Adding MSChart control dymanically in vb

Posted on 2004-08-18
8
2,828 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
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

This article will show, step by step, how to integrate R code into a R Sweave document
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 …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

830 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