graph in vb
Printable View
graph in vb
MSChart Control.
Would you care to share a few more words? ;)
put a command button named cmdRun on your form and a Graph1 on your form. Paste this code in the window and play with it. I got this off the net.
Code:Private Sub cmdRun_Click()
Dim i As Integer
'
' This tells the graph what type of graph you need
' Options included are: gphArea,gphBar2D,gphBar3D,
' gphGantt,gphHLC,gphLine,gphLogLin,gphNone,gphPie2D
' gphPie3D,gphPolar,gphScatter
'
Graph1.GraphType = 4 ' put this number to the style you want
'
' Clears Graph
'
Graph1.DataReset = gphAllData
'
' NumPoints = 20 must be correct or you'll get an error
'
Graph1.NumPoints = 20
'
' Allows for multiple lines (This example has only one line)
'
Graph1.NumSets = 1
'
' This must be set to 0 for the x-y plotting to work
' I have no idea why!
'
Graph1.AutoInc = 0
'
' This is a good example how VB has taken something totally
' simple and made it complicated (4 lines to do the work of 1)
'
For i = 1 To 20
Graph1.ThisSet = 1
Graph1.ThisPoint = i
Graph1.GraphData = Sin(i * 3.1415 / 10)
Graph1.LabelText = Format(3.1415 * i / 5, "##0.00")
Next i
'
' Set the y axis scale. This took me two days to figure out
' You need to click on the graph go to properties select
' (Custom) click on scales and pick user defined or the
' yAxisMin-Max will not work. Isn't that clever?
'
Graph1.YAxisMax = 1.5
Graph1.YAxisMin = -1.5
'
' Draws the graph
'
Graph1.DrawMode = gphDraw
End Sub
kokopeli or anyone who knows:
- what kind of object are you using "Graph1" is it MSChart? - How do I get hold of the object, so I can use it within VB6?
- Can I use that object when I'm creating my own activeX object?
Look in bbng's other questions. Someone left a link to MSDN site. You have to remove Option Explicit in the example they give you.
Hi.
Graph1 came from the library GraphLib (see the example).
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Object = "{0842D103-1E19-101B-9AAF-1A1626551E7C}#1.0#0"; "graph32.ocx"
Object = "{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}#1.0#0"; "threed32.ocx"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MShflxgd.ocx"
Begin GraphLib.Graph GRAPH1
Height = 5895
Left = 240
TabIndex = 10
Top = 120
Width = 6015
_Version = 65536
_ExtentX = 10610
_ExtentY = 10398
_StockProps = 96
BorderStyle = 1
BottomTitle = "Frequency MHz"
GraphStyle = 4
GraphType = 6
GridStyle = 3
IndexStyle = 1
LeftTitle = "System Return Loss dB"
LegendStyle = 1
RandomData = 0
ThickLines = 0
YAxisMax = -20
YAxisMin = -40
YAxisStyle = 2
ColorData = 0
ExtraData = 0
ExtraData[] = 0
FontFamily = 4
FontSize = 4
FontSize[0] = 200
FontSize[1] = 150
FontSize[2] = 100
FontSize[3] = 100
FontStyle = 4
GraphData = 1
GraphData[] = 5
GraphData[0,0] = 0
GraphData[0,1] = 0
GraphData[0,2] = 0
GraphData[0,3] = 0
GraphData[0,4] = 0
LabelText = 0
LegendText = 0
PatternData = 1
PatternData[0] = 5
SymbolData = 3
SymbolData[1] = 3
SymbolData[2] = 1
XPosData = 0
XPosData[] = 0
End
PS. I have used this 4 object too. Actually not every object is mandatory.
ComDlg32.OCX, graph32.ocx, threed32.ocx, MShflxgd.ocx;
Hi.
I use it with VB6.
Maybe it works with VB5 too.
Graph1 came from the library GraphLib (see the example).
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Object = "{0842D103-1E19-101B-9AAF-1A1626551E7C}#1.0#0"; "graph32.ocx"
Object = "{0BA686C6-F7D3-101A-993E-0000C0EF6F5E}#1.0#0"; "threed32.ocx"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MShflxgd.ocx"
Begin GraphLib.Graph GRAPH1
Height = 5895
Left = 240
TabIndex = 10
Top = 120
Width = 6015
_Version = 65536
_ExtentX = 10610
_ExtentY = 10398
_StockProps = 96
BorderStyle = 1
BottomTitle = "Frequency MHz"
GraphStyle = 4
GraphType = 6
GridStyle = 3
IndexStyle = 1
LeftTitle = "System Return Loss dB"
LegendStyle = 1
RandomData = 0
ThickLines = 0
YAxisMax = -20
YAxisMin = -40
YAxisStyle = 2
ColorData = 0
ExtraData = 0
ExtraData[] = 0
FontFamily = 4
FontSize = 4
FontSize[0] = 200
FontSize[1] = 150
FontSize[2] = 100
FontSize[3] = 100
FontStyle = 4
GraphData = 1
GraphData[] = 5
GraphData[0,0] = 0
GraphData[0,1] = 0
GraphData[0,2] = 0
GraphData[0,3] = 0
GraphData[0,4] = 0
LabelText = 0
LegendText = 0
PatternData = 1
PatternData[0] = 5
SymbolData = 3
SymbolData[1] = 3
SymbolData[2] = 1
XPosData = 0
XPosData[] = 0
End
PS. I have used this 4 object too. Actually not every object is mandatory.
ComDlg32.OCX, graph32.ocx, threed32.ocx, MShflxgd.ocx;
If wanting to use graph32.ocx, suggest reading this other thread
http://www.vbforums.com/showthread.p...57-Vb6-graph32
Oh, and any suggestion to remove Option Explicit is not a good suggestion IMO. If you get compile errors due to variables not declared, simply fix that by declaring the variables.
It was a reply to a thread dating back to 2000, 19 years ago...
I don't think the Topic Starter is still waiting for an answer :bigyello:
Yeah, it's old...but it's also pretty odd. Is this a response to a different question?