当前位置: 源码素材网 » VB教程 » 详情页

VB6.0 利用饼型图分析产品市场占有率

  •   时间:2020-04-18
  • 概述:图表 圆饼图

VB6.0 利用饼型图分析产品市场占有率,学习一下如何在VB中生成饼图,其实挺简单的,下面是完整的代码:

VERSION 5.00
Object = "{65E121D4-0C60-11D2-A9FC-0000F8754DA1}#2.0#0"; "mschrt20.ocx"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1 
   Caption         =   "VB6.0利用饼型图分析产品市场占有率"
   ClientHeight    =   6210
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9645
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   ScaleHeight     =   6210
   ScaleWidth      =   9645
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "退出"
      Height          =   360
      Left            =   8385
      TabIndex        =   2
      Top             =   5790
      Width           =   1245
   End
   Begin MSAdodcLib.Adodc Adodc2 
      Height          =   420
      Left            =   7035
      Top             =   4770
      Visible         =   0   'False
      Width           =   2550
      _ExtentX        =   4498
      _ExtentY        =   741
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   1
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=eg.mdb;Persist Security Info=False"
      OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=eg.mdb;Persist Security Info=False"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "select * from tb_stock"
      Caption         =   "Adodc2"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin VB.CommandButton Command1 
      Caption         =   "分析产品市场占有率"
      Height          =   360
      Left            =   5850
      TabIndex        =   1
      Top             =   5790
      Width           =   2475
   End
   Begin MSAdodcLib.Adodc Adodc1 
      Height          =   420
      Left            =   7035
      Top             =   5205
      Visible         =   0   'False
      Width           =   2550
      _ExtentX        =   4498
      _ExtentY        =   741
      ConnectMode     =   0
      CursorLocation  =   3
      IsolationLevel  =   -1
      ConnectionTimeout=   15
      CommandTimeout  =   30
      CursorType      =   3
      LockType        =   3
      CommandType     =   1
      CursorOptions   =   0
      CacheSize       =   50
      MaxRecords      =   0
      BOFAction       =   0
      EOFAction       =   0
      ConnectStringType=   1
      Appearance      =   1
      BackColor       =   -2147483643
      ForeColor       =   -2147483640
      Orientation     =   0
      Enabled         =   -1
      Connect         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=eg.mdb;Persist Security Info=False"
      OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=eg.mdb;Persist Security Info=False"
      OLEDBFile       =   ""
      DataSourceName  =   ""
      OtherAttributes =   ""
      UserName        =   ""
      Password        =   ""
      RecordSource    =   "select * from tb_stock"
      Caption         =   "Adodc1"
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      _Version        =   393216
   End
   Begin MSChart20Lib.MSChart MSChart1 
      Height          =   5685
      Left            =   30
      OleObjectBlob   =   "Form1.frx":0000
      TabIndex        =   0
      Top             =   30
      Width           =   9570
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
  Adodc1.RecordSource = "select 商品名称,市场占有数量 from tb_stock order by 市场占有数量 desc"
  Adodc1.Refresh
  Adodc2.RecordSource = "select sum(市场占有数量) as 数量 from tb_stock "
  Adodc2.Refresh
  MSChart1.ColumnCount = Adodc1.Recordset.RecordCount
  If Adodc1.Recordset.RecordCount > 0 Then     '当记录大于零时
     For i = 1 To Adodc1.Recordset.RecordCount
         MSChart1.Column = i
         MSChart1.Row = 1
         MSChart1.ColumnLabel = Adodc1.Recordset.Fields(0).Value & "占市场:" & Format(Adodc1.Recordset.Fields(1) / Adodc2.Recordset.Fields(0).Value, "0.00%")
         MSChart1.Data = Adodc1.Recordset.Fields(1).Value
         Adodc1.Recordset.MoveNext
     Next i
  End If
  MSChart1.RowCount = 1
  MSChart1.RowLabel = "利用饼型图分析产品市场占有率"
End Sub
Private Sub Command2_Click()
  End
End Sub
Private Sub Form_Load()
  Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\eg.mdb;Persist Security Info=False"
  MSChart1.chartType = VtChChartType2dPie
End Sub

    相关声明:

      若“VB6.0 利用饼型图分析产品市场占有率”有损您的权益,请告之我们删除内容。
      部分文章来源于网络,版权归原作者所有。