📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
AutoRedraw = -1 'True
Caption = "Form1"
ClientHeight = 5955
ClientLeft = 60
ClientTop = 2820
ClientWidth = 8880
LinkTopic = "Form1"
ScaleHeight = 5955
ScaleWidth = 8880
Begin VB.PictureBox picvalue
AutoRedraw = -1 'True
Height = 4455
Left = 600
ScaleHeight = 4395
ScaleWidth = 7875
TabIndex = 6
Top = 960
Width = 7935
Begin VB.Label y_val
AutoSize = -1 'True
Caption = "0"
Height = 195
Left = 6240
TabIndex = 11
Top = 360
Width = 90
End
Begin VB.Label x_val
AutoSize = -1 'True
Caption = "0"
Height = 195
Left = 5760
TabIndex = 10
Top = 360
Width = 90
End
End
Begin VB.CommandButton Command1
Caption = "取值"
Height = 375
Left = 3840
TabIndex = 3
Top = 360
Width = 1455
End
Begin VB.ComboBox cmbchannel
Height = 315
Index = 1
Left = 2640
TabIndex = 2
Text = "0"
Top = 360
Width = 975
End
Begin VB.ComboBox cmbchannel
Height = 315
Index = 0
Left = 1440
TabIndex = 1
Text = "0"
Top = 360
Width = 975
End
Begin VB.Label lblmarker
AutoSize = -1 'True
Caption = "x= y="
Height = 195
Left = 5760
TabIndex = 9
Top = 600
Width = 375
End
Begin VB.Label lblmaxx
AutoSize = -1 'True
Caption = "100"
Height = 195
Left = 8280
TabIndex = 8
Top = 5520
Width = 270
End
Begin VB.Label lblminx
AutoSize = -1 'True
Caption = "0"
Height = 195
Left = 600
TabIndex = 7
Top = 5520
Width = 90
End
Begin VB.Label lblminy
AutoSize = -1 'True
Caption = "10"
Height = 195
Left = 120
TabIndex = 5
Top = 5160
Width = 180
End
Begin VB.Label lblmaxy
AutoSize = -1 'True
Caption = "10"
Height = 195
Left = 120
TabIndex = 4
Top = 1200
Width = 180
End
Begin VB.Label Label1
Alignment = 2 'Center
AutoSize = -1 'True
Caption = "通道号码"
BeginProperty Font
Name = "楷体_GB2312"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 345
Left = 330
TabIndex = 0
Top = 360
Width = 960
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const pi = 3.1415926
Dim prex!, prey!, prey1!, prey2!, prex1!, prex2!
Dim preh_x_val!, preh_y_val!, prel_x_val!, prel_y_val!
Dim fmarker As Boolean
Dim scaledata(1, 99)
Private Sub Command1_Click()
Dim i&, max!, min!, j%
' ReDim scaledata(2, 50)
j = 0
For i = 0 To 99
scaledata(0, i) = Sin(i / 100 * 4 * pi)
scaledata(1, i) = 0.1 * Tan(i / 100 * 4 * pi)
Next
max = -10: min = 10
For j = 0 To 1
For i = 0 To UBound(scaledata, 2)
If scaledata(j, i) > max Then max = scaledata(j, i)
If scaledata(j, i) < min Then min = scaledata(j, i)
Next i
Next j
max = max * 1.1: min = min * 1.1
lblminy.Caption = Format(min, "0.000")
lblmaxy.Caption = Format(max, "0.000")
picvalue.Cls
picvalue.ForeColor = RGB(255, 0, 0)
picvalue.Scale (0, max)-(UBound(scaledata, 2) + 1, min)
For j = 0 To 1
If j = 0 Then picvalue.ForeColor = RGB(255, 0, 0)
If j = 1 Then picvalue.ForeColor = RGB(0, 0, 255)
picvalue.PSet (0, scaledata(j, 0))
For i = 1 To UBound(scaledata, 2)
picvalue.Line -(i, scaledata(j, i))
Next i
Next j
fmarker = False
End Sub
Private Sub Form_Load()
Dim i%, j%
For j = 0 To 1
cmbchannel(j).Clear
For i = 0 To 7
cmbchannel(j).AddItem CStr(i)
Next i
cmbchannel(j).ListIndex = j
Next j
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim olddrawmode As Integer
If fmarker = True Then
olddrawmode = picvalue.DrawMode
picvalue.DrawMode = vbXorPen
picvalue.DrawStyle = vbDot
picvalue.ForeColor = RGB(255, 255, 255)
picvalue.Line (prex, prey1)-(prex, prey2)
picvalue.Line (prex1, prey)-(prex2, prey)
picvalue.DrawMode = olddrawmode
picvalue.DrawStyle = vbsoid
fmarker = False
End If
End Sub
Private Sub picvalue_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim xval!
Dim olddrawmode As Integer
xval = X / 100 * (Val(lblmaxx.Caption) - Val(lblminx.Caption))
lblmarker.Caption = "X=" & Format(xval, "0.00") & ",Y=" & Format(Y, "0.00")
olddrawmode = picvalue.DrawMode
picvalue.DrawMode = vbXorPen
picvalue.DrawStyle = vbDot
picvalue.ForeColor = RGB(255, 255, 255)
If Not fmarker Then
picvalue.Line (X, Val(lblminy.Caption))-(X, Val(lblmaxy.Caption))
picvalue.Line (Val(lblminx.Caption), Y)-(Val(lblmaxx.Caption), Y)
x_val.Top = Y + x_val.Height
' y_val.Height = Y - 1
x_val.Left = X
' y_val.Left = X
Else
picvalue.Line (prex, prey1)-(prex, prey2)
picvalue.Line (X, Val(lblminy.Caption))-(X, Val(lblmaxy.Caption))
picvalue.Line (prex1, prey)-(prex2, prey)
picvalue.Line (Val(lblminx.Caption), Y)-(Val(lblmaxx.Caption), Y)
x_val.Top = preh_x_val + x_val.Height
x_val.Top = Y + x_val.Height
' y_val.Height = preh_y_val
' y_val.Height = Y
x_val.Left = prel_x_val 'first
If (X + x_val.Width) > Val(lblmaxx.Caption) Then
x_val.Left = X - x_val.Width
Else
x_val.Left = X
End If
' y_val.Left = prel_y_val
' y_val.Left = X
End If
fmarker = True
x_val.Caption = "X=" & Format(xval, "0.00") & ",Y=" & Format(Y, "0.00")
prex = X
prey = Y
prey1 = Val(lblminy.Caption)
prey2 = Val(lblmaxy.Caption)
prex1 = Val(lblminx.Caption)
prex2 = Val(lblmaxx.Caption)
preh_x_val = x_val.Top
prel_x_val = x_val.Left
' preh_y_val = y_val.top
' prel_y_val = y_val.Left
picvalue.DrawMode = olddrawmode
picvalue.DrawStyle = vbsoid
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -