I have a string:
ChartDataStr = "aa,\21,22,23,34,44,45,55,64,73,82,91,21\" _
& "0,2,4,6,8,10,10,8,6,4,2,0\" _
& "0,4,6,8,10,12,12,10,8,6,4,0\" _
& "0,6,8,10,12,14,14,12,10,8,6,0\" _
& "0,8,10,12,14,16,16,14,12,10,8,0\" _
& "0,10,12,14,16,18,18,16,14,12,10,0\" _
& "0,12,14,16,18,20,20,18,16,14,12,0\" _
& "0,14,16,18,20,22,22,20,18,16,14,0\" _
& "0,16,18,20,22,24,24,22,20,18,16,0\" _
& "0,18,20,22,24,26,26,24,22,20,18,0\bb"
That represents several charts, in this case 10, that I can parse into individual charts into an Chartsarr( ) array where each has the form:
21,22,23,34,44,45,55,64,73,82,91,21
I can then select the chart desired with ChartDesired - Chartsarr(ChartDesired)
I can parse each chart by replacing the ,’s with a space, and place the individual value of data points into another array – ChartPointPointarr( ).
What I can’t figure out is how to get the Chartsarr(ChartDesired) - ChartPointPointarr( )
Into the MSChart:
.ChartData = Chartsarr(ChartDesired)?????
Any help would be appreciated.
Thanks,
Gary
Public Sub CmdGetCharts_Click()
Dim ChartDataStr As String
ChartDataStr = "aa,\21,22,23,34,44,45,55,64,73,82,91,21\" _
& "0,2,4,6,8,10,10,8,6,4,2,0\" _
& "0,4,6,8,10,12,12,10,8,6,4,0\" _
& "0,6,8,10,12,14,14,12,10,8,6,0\" _
& "0,8,10,12,14,16,16,14,12,10,8,0\" _
& "0,10,12,14,16,18,18,16,14,12,10,0\" _
& "0,12,14,16,18,20,20,18,16,14,12,0\" _
& "0,14,16,18,20,22,22,20,18,16,14,0\" _
& "0,16,18,20,22,24,24,22,20,18,16,0\" _
& "0,18,20,22,24,26,26,24,22,20,18,0\bb"
ChartDataLen = Len(ChartDataStr) 'Length of the Chart Data string
ChartsQty = "\"
If Len(ChartsQty) Then
ChartsCount = UBound(Split(ChartDataStr, ChartsQty)) 'Find out how many \ there are
End If
LblChartsAvailable.Caption = ChartsCount - 1
ChartCharStartPos = 5 'this is the position after the header
ReDim Chartsarr(1 To ChartsCount) 'set the number of arrays to the number of charts counted
For MakeCharts = 1 To (ChartsCount - 1) 'Calculate the number of charts
ChartCharPos = InStr(ChartCharStartPos + 2, ChartDataStr, "\") 'find the first "\" - get the string up to that position, then set the search to that position plus 1
ChartQtyToRead = ChartCharPos - ChartCharStartPos
Chartsarr(MakeCharts) = Mid$(ChartDataStr, ChartCharStartPos, ChartQtyToRead)
CommaCount = UBound(Split(Chartsarr(MakeCharts), ",")) 'count the commas
ChartPointQty = CommaCount + 2
Chartsarr(MakeCharts) = Replace$(Chartsarr(MakeCharts), ",", " ") 'replace commas with spaces
' **************** this will separate each data point into an individual graph point *****************
ReDim ChartPointPointarr(1 To ChartPointQty) 'set the number of point arrays to the number of points counted
ChartPointStartPos = 1
ChartPointLen = Len(Chartsarr(MakeCharts))
ChartLastPos = InStrRev(Chartsarr(MakeCharts), " ")
For MakePoints = 1 To (ChartPointQty - 1) 'Calculate the number of points
ChartPointPos = InStr(ChartPointStartPos, Chartsarr(MakeCharts), " ") 'find the first " " - get the string up to that position, then set the search to that position plus 1
UseThisData = Chartsarr(MakeCharts)
ChartPointQtyToRead = ChartPointPos - ChartPointStartPos
If ChartPointStartPos >= ChartLastPos Then
ChartPointStartPos = ChartLastPos + 1
ChartPointQtyToRead = ChartPointLen - ChartLastPos
End If
ChartPointPointarr(MakePoints) = Val(Mid$(UseThisData, ChartPointStartPos, ChartPointQtyToRead))
ChartPointStartPos = ChartPointStartPos + ChartPointQtyToRead + 1
Next MakePoints
ChartCharStartPos = ChartCharPos + 1
Next MakeCharts
End Sub
Private Sub cmdDrawGraph_Click()
If ChartDesired = 0 Then
MsgBox "Select Graph", vbExclamation, "Select Graph"
Exit Sub
End If
With MSChart1
.ChartType = VtChChartType2dLine
.ShowLegend = True
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Name = ariel
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Size = 12
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Style = Bold
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.VtColor.Set 204, 204, 204
.TitleText = "FLOW GRAPH"
.ChartData = Chartsarr(ChartDesired)
With .DataGrid
.SetSize 1, 7, 125, 7 '(rowLabelCount, columnLabelCount, dataRowCount, columnLabelCount)
Dim intIndex As Integer '*******************
MSChart1.RowCount = 125
End With
With .Plot
With .Axis(VtChAxisIdY).ValueScale
.Auto = False
.Minimum = 0
.Maximum = 100
End With
With .Axis(VtChAxisIdX).AxisGrid
.MajorPen.VtColor.Set 204, 204, 204
.MajorPen.Width = 2
.MinorPen.VtColor.Set 204, 204, 204
.MinorPen.Width = 2
End With
With .Axis(VtChAxisIdY).AxisGrid
.MajorPen.VtColor.Set 204, 204, 204
.MajorPen.Width = 2
.MinorPen.VtColor.Set 204, 204, 204
.MinorPen.Width = 2
End With
With .Item(1).DataPoints(-1) 'controls text for flow line - grid too small - can't see the text
.DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
.DataPointLabel.VtFont.VtColor.Set 0, 0, 0 '# black text
.Brush.FillColor.Set 255, 0, 0 '# red line
End With
With .Item(2).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 0, 102, 255 '# blue
.Brush.FillColor.Set 0, 102, 255
End With
With .Item(3).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 0, 102, 255 '# blue
.Brush.FillColor.Set 0, 102, 255
End With
With .Item(4).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 0, 204, 0 '# green
.Brush.FillColor.Set 0, 204, 0
End With
With .Item(5).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 204, 204, 204 '# green
.Brush.FillColor.Set 0, 204, 0
End With
With .Item(6).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 205, 153, 0 '# brown
.Brush.FillColor.Set 205, 153, 0
End With
With .Item(7).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 205, 153, 0 '# brown
.Brush.FillColor.Set 205, 153, 0
End With
End With '#seriescoll
End With '# plot
End With '#chart
End Sub
ChartDataStr = "aa,\21,22,23,34,44,45,55,64,73,82,91,21\" _
& "0,2,4,6,8,10,10,8,6,4,2,0\" _
& "0,4,6,8,10,12,12,10,8,6,4,0\" _
& "0,6,8,10,12,14,14,12,10,8,6,0\" _
& "0,8,10,12,14,16,16,14,12,10,8,0\" _
& "0,10,12,14,16,18,18,16,14,12,10,0\" _
& "0,12,14,16,18,20,20,18,16,14,12,0\" _
& "0,14,16,18,20,22,22,20,18,16,14,0\" _
& "0,16,18,20,22,24,24,22,20,18,16,0\" _
& "0,18,20,22,24,26,26,24,22,20,18,0\bb"
That represents several charts, in this case 10, that I can parse into individual charts into an Chartsarr( ) array where each has the form:
21,22,23,34,44,45,55,64,73,82,91,21
I can then select the chart desired with ChartDesired - Chartsarr(ChartDesired)
I can parse each chart by replacing the ,’s with a space, and place the individual value of data points into another array – ChartPointPointarr( ).
What I can’t figure out is how to get the Chartsarr(ChartDesired) - ChartPointPointarr( )
Into the MSChart:
.ChartData = Chartsarr(ChartDesired)?????
Any help would be appreciated.
Thanks,
Gary
Public Sub CmdGetCharts_Click()
Dim ChartDataStr As String
ChartDataStr = "aa,\21,22,23,34,44,45,55,64,73,82,91,21\" _
& "0,2,4,6,8,10,10,8,6,4,2,0\" _
& "0,4,6,8,10,12,12,10,8,6,4,0\" _
& "0,6,8,10,12,14,14,12,10,8,6,0\" _
& "0,8,10,12,14,16,16,14,12,10,8,0\" _
& "0,10,12,14,16,18,18,16,14,12,10,0\" _
& "0,12,14,16,18,20,20,18,16,14,12,0\" _
& "0,14,16,18,20,22,22,20,18,16,14,0\" _
& "0,16,18,20,22,24,24,22,20,18,16,0\" _
& "0,18,20,22,24,26,26,24,22,20,18,0\bb"
ChartDataLen = Len(ChartDataStr) 'Length of the Chart Data string
ChartsQty = "\"
If Len(ChartsQty) Then
ChartsCount = UBound(Split(ChartDataStr, ChartsQty)) 'Find out how many \ there are
End If
LblChartsAvailable.Caption = ChartsCount - 1
ChartCharStartPos = 5 'this is the position after the header
ReDim Chartsarr(1 To ChartsCount) 'set the number of arrays to the number of charts counted
For MakeCharts = 1 To (ChartsCount - 1) 'Calculate the number of charts
ChartCharPos = InStr(ChartCharStartPos + 2, ChartDataStr, "\") 'find the first "\" - get the string up to that position, then set the search to that position plus 1
ChartQtyToRead = ChartCharPos - ChartCharStartPos
Chartsarr(MakeCharts) = Mid$(ChartDataStr, ChartCharStartPos, ChartQtyToRead)
CommaCount = UBound(Split(Chartsarr(MakeCharts), ",")) 'count the commas
ChartPointQty = CommaCount + 2
Chartsarr(MakeCharts) = Replace$(Chartsarr(MakeCharts), ",", " ") 'replace commas with spaces
' **************** this will separate each data point into an individual graph point *****************
ReDim ChartPointPointarr(1 To ChartPointQty) 'set the number of point arrays to the number of points counted
ChartPointStartPos = 1
ChartPointLen = Len(Chartsarr(MakeCharts))
ChartLastPos = InStrRev(Chartsarr(MakeCharts), " ")
For MakePoints = 1 To (ChartPointQty - 1) 'Calculate the number of points
ChartPointPos = InStr(ChartPointStartPos, Chartsarr(MakeCharts), " ") 'find the first " " - get the string up to that position, then set the search to that position plus 1
UseThisData = Chartsarr(MakeCharts)
ChartPointQtyToRead = ChartPointPos - ChartPointStartPos
If ChartPointStartPos >= ChartLastPos Then
ChartPointStartPos = ChartLastPos + 1
ChartPointQtyToRead = ChartPointLen - ChartLastPos
End If
ChartPointPointarr(MakePoints) = Val(Mid$(UseThisData, ChartPointStartPos, ChartPointQtyToRead))
ChartPointStartPos = ChartPointStartPos + ChartPointQtyToRead + 1
Next MakePoints
ChartCharStartPos = ChartCharPos + 1
Next MakeCharts
End Sub
Private Sub cmdDrawGraph_Click()
If ChartDesired = 0 Then
MsgBox "Select Graph", vbExclamation, "Select Graph"
Exit Sub
End If
With MSChart1
.ChartType = VtChChartType2dLine
.ShowLegend = True
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Name = ariel
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Size = 12
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.Style = Bold
.Plot.Axis(VtChAxisIdX).Labels(1).VtFont.VtColor.Set 204, 204, 204
.TitleText = "FLOW GRAPH"
.ChartData = Chartsarr(ChartDesired)
With .DataGrid
.SetSize 1, 7, 125, 7 '(rowLabelCount, columnLabelCount, dataRowCount, columnLabelCount)
Dim intIndex As Integer '*******************
MSChart1.RowCount = 125
End With
With .Plot
With .Axis(VtChAxisIdY).ValueScale
.Auto = False
.Minimum = 0
.Maximum = 100
End With
With .Axis(VtChAxisIdX).AxisGrid
.MajorPen.VtColor.Set 204, 204, 204
.MajorPen.Width = 2
.MinorPen.VtColor.Set 204, 204, 204
.MinorPen.Width = 2
End With
With .Axis(VtChAxisIdY).AxisGrid
.MajorPen.VtColor.Set 204, 204, 204
.MajorPen.Width = 2
.MinorPen.VtColor.Set 204, 204, 204
.MinorPen.Width = 2
End With
With .Item(1).DataPoints(-1) 'controls text for flow line - grid too small - can't see the text
.DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
.DataPointLabel.VtFont.VtColor.Set 0, 0, 0 '# black text
.Brush.FillColor.Set 255, 0, 0 '# red line
End With
With .Item(2).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 0, 102, 255 '# blue
.Brush.FillColor.Set 0, 102, 255
End With
With .Item(3).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 0, 102, 255 '# blue
.Brush.FillColor.Set 0, 102, 255
End With
With .Item(4).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 0, 204, 0 '# green
.Brush.FillColor.Set 0, 204, 0
End With
With .Item(5).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 204, 204, 204 '# green
.Brush.FillColor.Set 0, 204, 0
End With
With .Item(6).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 205, 153, 0 '# brown
.Brush.FillColor.Set 205, 153, 0
End With
With .Item(7).DataPoints(-1)
.DataPointLabel.VtFont.VtColor.Set 205, 153, 0 '# brown
.Brush.FillColor.Set 205, 153, 0
End With
End With '#seriescoll
End With '# plot
End With '#chart
End Sub