| |

VerySource

 Forgot password?
 Register
Search
View: 629|Reply: 8

mschart array problem ~

[Copy link]

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-2-8 09:30:01
| Show all posts |Read mode
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
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-3-30 18:45:01
| Show all posts
LZ How did you use the MSChart control? I'm anxious about it. I don't know how to program with it. Can you send me your code? Thank you.
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-3-30 19:45:01
| Show all posts
Are you using Microsoft Office Chart 11.0?
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-3-31 11:00:02
| Show all posts
I don't know too ~ I'm anxious here too, I just use the little code above, or COPY from MSDE ~
Not Microsoft Office Chart 11.0
Is Microsoft chart contorl
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-4-1 11:15:02
| Show all posts
Which control do you have? Send me one and let's work together
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-1 21:30:02
| Show all posts
... Vs.net comes with it ~
You click on the toolbox and then click on add and remove items. Inside you can find the Microsoft chart control. Then confirm it and it will be displayed in the toolbox.
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-4-3 23:30:01
| Show all posts
I was dizzy. It turned out to be Microsoft chart control 6.0. I chose Microsoft Office Chart 11.0. I thought that Microsoft Office Chart 11.0 was MSChart. After a long time of doing it, no wonder I always make mistakes. I finally understand
Reply

Use magic Report

1

Threads

9

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-4-4 03:00:02
| Show all posts
Its practical Microsoft Office Chart 11.0 is better to do, but I just do n’t know how to program it
OWC11 is also available
Reply

Use magic Report

1

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

 Author| Post time: 2020-4-8 19:15:01
| Show all posts
Oh ~ I won't
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list