?
Solved

Adding MSChart control dymanically in vb

Posted on 2004-08-18
8
Medium Priority
?
2,863 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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 500 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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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 SignAloud Glove is capable of translating American Sign Language signs into text and audio.
Simple Linear Regression
Introduction to Processes
Suggested Courses

762 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