|
Dim sql As String, i
Dim yf (2) As Object, sal (1, 11) As Object, yy (2) As Object
'With yf
yf (0) = "Company"
yf (1) = "Practical Water Volume"
yf (2) = "Water payable"
'' End With
'' sal (0) = yf
Dim y, s, yj
For i = 0 To 11
Conn.Open ()
sql = "SELECT SUM (payable degree) AS payable amount, SUM (utility degree) AS practical water amount, year, month FROM water consumption (year = 2016) AND (month ="&i + 1&") GROUP BY Year, month "
Dim sqlcmd As New SqlCommand (sql, Conn)
Dim rs As SqlDataReader = sqlcmd.ExecuteReader ()
If rs.HasRows = True Then
rs.Read ()
y = rs ("month")
s = rs ("Utility Water")
yj = rs ("Water payable")
Else
y = i + 1
s = 0
yj = 0
End If
'MsgBox (y&"/"&s&"/"&yj)
yy (0) = y&"month"
yy (1) = s
yy (2) = yj
Conn.Close ()
sal (0, i) = yy
Next
Dim Sales (,) As Object = New Object (,) {(yf}, {sal (0, 11)}}
'Dim Sales (,) As Object = New Object (,) _
'{{"Company", "Company A", "Company B"}, _
'{"June", 20, 10}, _
'{"July", 10, 5}, _
'{"August", 30, 15}, _
'{"September", 14, 7}}
chtSales.ChartData = Sales
'Add a title and legend.
With Me.chtSales
.Title.Text = "test"
.Legend.Location.LocationType = _
MSChart20Lib.VtChLocationType.VtChLocationTypeBottom
.Legend.Location.Visible = True
End With
'Add titles to the axes.
With Me.chtSales.Plot
.Axis (MSChart20Lib.VtChAxisId.VtChAxisIdX) .AxisTitle.Text = "Year"
.Axis (MSChart20Lib.VtChAxisId.VtChAxisIdY) .AxisTitle.Text = "Millions of $"
End With
Dim r, g, b
'Set custom colors for the bars.
With Me.chtSales.Plot
'Yellow for Company A
'-1 selects all the datapoints.
For i = 1 To 1
r = CInt (Int ((250 * Rnd ()) + 0))
g = CInt (Int ((250 * Rnd ()) + 0))
b = CInt (Int ((250 * Rnd ()) + 0))
'Console.WriteLine (r&"/"&g&"/"&b)
.SeriesCollection (i) .DataPoints (-1) .Brush.FillColor.Set (r, g, b)
'Purple for Company B
'.SeriesCollection (2) .DataPoints (-1) .Brush.FillColor.Set (200, 50, 200)
Next
End With
Brothers and sisters, how to make the array look like the following? what should I do?
Dim Sales (,) As Object = New Object (,) _
{{"Company", "Company A", "Company B"}, _
{"June", 20, 10}, _
{"July", 10, 5}, _
{"August", 30, 15}, _
{"September", 14, 7}}
===================================================
I read the database to build the array, I built it wrong ~ I hope you big brother and sister help me, what should I do?
Dim sql As String, i
Dim yf (2) As Object, sal (1, 11) As Object, yy (2) As Object
'With yf
yf (0) = "Company"
yf (1) = "Practical Water Volume"
yf (2) = "Water payable"
'' End With
'' sal (0) = yf
Dim y, s, yj
For i = 0 To 11
Conn.Open ()
sql = "SELECT SUM (payable degree) AS payable amount, SUM (utility degree) AS practical water amount, year, month FROM water consumption (year = 2016) AND (month ="&i + 1&") GROUP BY Year, month "
Dim sqlcmd As New SqlCommand (sql, Conn)
Dim rs As SqlDataReader = sqlcmd.ExecuteReader ()
If rs.HasRows = True Then
rs.Read ()
y = rs ("month")
s = rs ("Utility Water")
yj = rs ("Water payable")
Else
y = i + 1
s = 0
yj = 0
End If
'MsgBox (y&"/"&s&"/"&yj)
yy (0) = y&"month"
yy (1) = s
yy (2) = yj
Conn.Close ()
sal (0, i) = yy
Next |
|