📄 module1.bas
字号:
Attribute VB_Name = "Module1"
Public minvalue, maxvalue, mintime, maxtime As Double
Public temp(), data() As Variant
Public mtop, mbottom, mleft, mright, mcount, mtemp, trvindex, mhead, maxnum As Integer
Public Sub drawzx(ByVal head As Integer, ByVal length As Integer, ByVal all_len As Integer)
Dim ttdata() As Variant
Dim j As Integer
Dim n As Integer
'Dim secdata(10, 1) As Double
n = UBound(data, 2)
ReDim ttdata(length - 1, n)
For i = 0 To length - 1
For k = 0 To n
ttdata(i, k) = data(head + i, k)
Next k
Next i
setxianshi ("ze")
'波形图外观设置
With Form1.MSChart1
.ColumnCount = n + 1
.TitleText = "速度 m/min"
.Plot.Axis(VtChAxisIdX).AxisTitle.Text = "时间"
.Plot.Axis(VtChAxisIdY).AxisTitle.Text = "数值"
' '设置图线的外观
.Plot.LocationRect.Min.Set 0, 0
For j = 1 To n
.Plot.SeriesCollection(j).Pen.Width = 1 '222
.Plot.SeriesCollection(j).Pen.Style = VtPenStyleSolid
j = j + 1
Next j
If n >= 1 Then
.Plot.SeriesCollection(1).LegendText = Form3.Combo2.Text
End If
If n >= 3 Then
.Plot.SeriesCollection(2).LegendText = Form3.Combo4.Text
End If
If n >= 5 Then
.Plot.SeriesCollection(3).LegendText = Form3.Combo6.Text
End If
If n >= 7 Then
.Plot.SeriesCollection(4).LegendText = Form3.Combo8.Text
End If
If n >= 9 Then
.Plot.SeriesCollection(5).LegendText = Form3.Combo10.Text
End If
' '设置XY轴
.Plot.Axis(VtChAxisIdX).ValueScale.Auto = True
.Plot.Axis(VtChAxisIdY).ValueScale.Auto = False
'// 设置最大值
' .Plot.Axis(VtChAxisIdX).ValueScale.Maximum = maxtime
' If maxvalue > 1 Then
' .Plot.Axis(VtChAxisIdY).ValueScale.Maximum = Round(maxvalue * 1.5, 0)
' End If
' If maxvalue > 0.1 Then
' .Plot.Axis(VtChAxisIdY).ValueScale.Maximum = Round(maxvalue * 1.5, 1)
' End If
' If maxvalue > 0.01 Then
' .Plot.Axis(VtChAxisIdY).ValueScale.Maximum = Round(maxvalue * 1.5, 2)
' End If
'
If maxvalue > 100 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = Round(maxvalue * 1.5)
ElseIf maxvalue > 75 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 100
ElseIf maxvalue > 50 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 75
ElseIf maxvalue > 30 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 50
ElseIf maxvalue > 20 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 30
ElseIf maxvalue > 10 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 20
ElseIf maxvalue > 5 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 10
ElseIf maxvalue > 3 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 5
ElseIf maxvalue > 1 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 3
ElseIf maxvalue > 0.5 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 1
ElseIf maxvalue > 0.3 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 0.5
ElseIf maxvalue > 0.1 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 0.3
ElseIf maxvalue > 0.05 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 0.1
ElseIf maxvalue > 0.03 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 0.05
ElseIf maxvalue > 0.01 Then
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = 0.03
Else
.Plot.Axis(VtChAxisIdY).ValueScale.Maximum = maxvalue * 1.5
End If
' '// 设置最小值
.Plot.Axis(VtChAxisIdY).ValueScale.Minimum = 0
' .Plot.Axis(VtChAxisIdX).ValueScale.Minimum = mintime
'//
'.Plot.Axis(VtChAxisIdX).ValueScale.MajorDivision = 6 'X轴主要网格数量
.Plot.Axis(VtChAxisIdY).ValueScale.MajorDivision = 5 'Y轴主要网格数量
' .Plot.Axis(VtChAxisIdX).ValueScale.MinorDivision = 0 'X轴次要网格数量
' .Plot.Axis(VtChAxisIdY).ValueScale.MinorDivision = 0 'Y轴次要网格数量
.Plot.Axis(VtChAxisIdX).AxisGrid.MajorPen.Style = VtPenStyleDotted
.Plot.Axis(VtChAxisIdY).AxisGrid.MajorPen.Style = VtPenStyleDotted
' MSChart1.ColumnCount = 2
' MSChart1.RowCount = 380
Form1.MSChart1.Plot.AutoLayout = False
Form1.MSChart1.Plot.UniformAxis = False
Form1.MSChart1.chartType = VtChChartType2dXY '设置图形为二维散点图
Form1.MSChart1.ChartData = ttdata '数据
End With
End Sub
Public Sub setxianshi(i As String)
If i = "grid" Then
Form1.VSPrinter1.Visible = False
Form1.cmmset.Visible = False
Form1.MSChart1.Visible = False
Form1.VSFG1.Visible = True
Form1.VSFG1.Top = 840
Form1.VSFG1.Left = 2640
End If
If i = "ze" Then
Form1.VSPrinter1.Visible = False
Form1.cmmset.Visible = False
Form1.MSChart1.Visible = True
Form1.VSFG1.Visible = False
Form1.MSChart1.Top = 840
Form1.MSChart1.Left = 2640
End If
If i = "prt" Then
Form1.VSPrinter1.Visible = True
Form1.cmmset.Visible = True
Form1.MSChart1.Visible = False
Form1.VSFG1.Visible = False
Form1.VSPrinter1.Top = 840
Form1.VSPrinter1.Left = 2640
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -