⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 图表_绘制f2.frm

📁 一个可以绘画的VB源代码
💻 FRM
字号:
VERSION 5.00
Object = "{65E121D4-0C60-11D2-A9FC-0000F8754DA1}#2.0#0"; "mschrt20.ocx"
Begin VB.Form frmPicture 
   Appearance      =   0  'Flat
   BackColor       =   &H80000005&
   Caption         =   "图表"
   ClientHeight    =   3540
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   2070
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   ScaleHeight     =   3540
   ScaleWidth      =   2070
   StartUpPosition =   3  '窗口缺省
   Begin VB.ListBox List1 
      Height          =   1500
      Left            =   120
      TabIndex        =   6
      Top             =   600
      Width           =   1215
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确  定"
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   2160
      Width           =   855
   End
   Begin MSChart20Lib.MSChart MSChart1 
      Height          =   7935
      Left            =   1320
      OleObjectBlob   =   "图表_绘制F2.frx":0000
      TabIndex        =   2
      Top             =   120
      Width           =   9015
   End
   Begin VB.CommandButton cmdExit 
      Caption         =   "退  出"
      Height          =   375
      Left            =   120
      TabIndex        =   3
      Top             =   3120
      Width           =   855
   End
   Begin VB.CommandButton cmdDraw 
      Caption         =   "作  图"
      Height          =   375
      Left            =   120
      TabIndex        =   0
      Top             =   2640
      Width           =   855
   End
   Begin VB.Label Label2 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "Label2"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   240
      TabIndex        =   5
      Top             =   360
      Width           =   1095
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      Caption         =   "选择图表类型"
      ForeColor       =   &H80000008&
      Height          =   255
      Left            =   120
      TabIndex        =   4
      Top             =   120
      Width           =   1335
   End
End
Attribute VB_Name = "frmPicture"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim intI As Integer, intJ As Integer
Dim intFileNumber As Integer
Dim strData As String           '临时保存数据
Dim dblData As Double           '双精度数据
Dim blnTitle As Boolean         '是否有图题
Dim blnRowLabel As Boolean      '是否有行标
Dim blnColLabel As Boolean      '是否有列标

Private Sub Form_Load()
    cmdDraw.Visible = False
    MSChart1.Visible = False
'在组合框内添加项目(图表类型)
    With List1
        .AddItem "3维条形图"
        .AddItem "2维条形图"
        .AddItem "3维折线图"
        .AddItem "2维折线图"
        .AddItem "3维域型图"
        .AddItem "2维域型图"
        .AddItem "3维阶梯图"
        .AddItem "2维阶梯图"
        .AddItem "3维联合图"
        .AddItem "2维联合图"
        .AddItem "2维饼形图"
        .AddItem "2维坐标图"
    End With
    List1.Text = "2维条形图"            '缺省的图表类型
    Label2.Caption = "2维条形图"
End Sub

'在标签内列出图表的类型
Private Sub List1_Click()
    Select Case List1.Text
        Case "3维条形图"
            Label2.Caption = "3维条形图"
            Me.Caption = "3维条形图"
            MSChart1.chartType = 0
        Case "2维条形图"
            Label2.Caption = "2维条形图"
            Me.Caption = "2维条形图"
            MSChart1.chartType = 1
        Case "3维折线图"
            Label2.Caption = "3维折线图"
            Me.Caption = "3维折线图"
            MSChart1.chartType = 2
        Case "2维折线图"
            Label2.Caption = "2维折线图"
            Me.Caption = "2维折线图"
            MSChart1.chartType = 3
        Case "3维域型图"
            Label2.Caption = "3维域型图"
            Me.Caption = "3维域型图"
            MSChart1.chartType = 4
        Case "2维域型图"
            Label2.Caption = "2维域型图"
            Me.Caption = "2维域型图"
            MSChart1.chartType = 5
        Case "3维阶梯图"
            Label2.Caption = "3维阶梯图"
            Me.Caption = "3维阶梯图"
            MSChart1.chartType = 6
        Case "2维阶梯图"
            Label2.Caption = "2维阶梯图"
            Me.Caption = "2维阶梯图"
            MSChart1.chartType = 7
        Case "3维联合图"
            Label2.Caption = "3维联合图"
            Me.Caption = "3维联合图"
            MSChart1.chartType = 8
        Case "2维联合图"
            Label2.Caption = "2维联合图"
            Me.Caption = "2维联合图"
            MSChart1.chartType = 9
        Case "2维饼形图"
            Label2.Caption = "2维饼形图"
            Me.Caption = "2维饼形图"
            MSChart1.chartType = 14
        Case "2维坐标图"
            Label2.Caption = "2维坐标图"
            Me.Caption = "2维坐标图"
            MSChart1.chartType = 16
    End Select
End Sub

'确定
Private Sub cmdOK_Click()
    Label1.Visible = False
    Label2.Visible = False
    List1.Visible = False
    cmdDraw.Visible = True
    MSChart1.Visible = True
    cmdOK.Visible = False
    Me.Height = 8775                '展开窗体时,窗体的高度
    Me.Width = 10635                '展开窗体时,窗体的宽度
End Sub

'作图
Private Sub cmdDraw_Click()
    cmdDraw.Visible = False
    Label1.Visible = False          '隐藏说明标签
    Label2.Visible = False          '隐藏形式图表类型标签
    List1.Visible = False           '隐藏组合框
    intFileNumber = FreeFile        '取得空闲的文件号码
    Open strFileName For Input As intFileNumber
    Input #intFileNumber, strData   '读列数
    intCol = Val(strData)           '取得列数
    If intCol >= 2 Then
        For intI = 2 To intCol      '空转,读*****
            Input #intFileNumber, strData
        Next intI
    End If
    Input #intFileNumber, strData   '读行数
    intRow = Val(strData)           '取得行数
    If intCol >= 2 Then
        For intI = 2 To intCol      '空转,读*****
            Input #intFileNumber, strData
        Next intI
    End If
    Input #intFileNumber, strData   '读总行数
    intRowAll = Val(strData)        '取得总行数
    If intCol >= 2 Then
        For intI = 2 To intCol      '空转,读*****
            Input #intFileNumber, strData
        Next intI
    End If
    blnTitle = False: blnRowLabel = False: blnColLabel = False
'优先考虑图题
    If intRowAll > intRow + 3 Then blnTitle = True          '有图题
'其次考虑行标
    If intRowAll > 2 * intRow + 3 Then blnRowLabel = True   '有行标
'最后考虑列标
    If intRowAll > 2 * intRow + 4 Then blnColLabel = True   '有列标
'设置图表控件属性
    With MSChart1
        .RowCount = intRow                              '数据行数
        If blnRowLabel Then .RowLabelCount = intRow     '数据行标数
        .ColumnCount = intCol                           '数据列数
        If blnColLabel Then .ColumnLabelCount = intCol  '数据列标数
        .AutoIncrement = True                           '数据点可以递增输入
        .ShowLegend = True                              '显示图例
    End With
    If blnTitle Then
        Input #intFileNumber, strData       '读图形标题
        MSChart1.TitleText = strData        '图形标题
        If intCol >= 2 Then
            For intI = 2 To intCol           '空转,读*****号
                Input #intFileNumber, strData
            Next intI
        End If
    End If
    If blnRowLabel Then
        For intI = 1 To intRow
            MSChart1.Row = intI
            Input #intFileNumber, strData   '读行标题
            MSChart1.RowLabel = strData     '行标题
            If intCol >= 2 Then
                For intJ = 2 To intCol      '空转,读*****号
                    Input #intFileNumber, strData
                Next intJ
            End If
        Next intI
    End If
    If blnColLabel Then
        For intI = 1 To intCol                  '读列标题
            Input #intFileNumber, strData
            MSChart1.Column = intI
            MSChart1.ColumnLabel = strData
        Next intI
    End If
'作图表
    For intI = 1 To intRow
        For intJ = 1 To intCol
            Input #intFileNumber, strData       '读数据
            dblData = Val(strData)
            MSChart1.DataGrid.SetData intI, intJ, dblData, False
        Next intJ
    Next intI
    Close
End Sub

'退出
Private Sub cmdExit_Click()
    Unload Me
    End
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -