[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Adding MSChart control dymanically in vb

Posted on 2004-08-18
8
Medium Priority
?
2,882 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

873 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