📄 read_frm.frm
字号:
VERSION 5.00
Begin VB.Form READ_FRM
Caption = "LESEN/READ"
ClientHeight = 5325
ClientLeft = 960
ClientTop = 570
ClientWidth = 7230
LinkTopic = "Form1"
ScaleHeight = 5325
ScaleWidth = 7230
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 600
Left = 2400
Top = 4800
End
Begin VB.CommandButton IDREAD
Caption = "lesen/read"
Height = 375
Left = 5040
TabIndex = 15
Top = 4800
Width = 1215
End
Begin VB.CommandButton IDCYCLEREAD
Caption = "cycle read"
Height = 375
Left = 3120
TabIndex = 14
Top = 4800
Width = 1335
End
Begin VB.CommandButton IDCANCEL
Caption = "zur點k/cancel"
Height = 375
Left = 240
TabIndex = 13
Top = 4800
Width = 1335
End
Begin VB.Frame Frame3
Height = 1335
Left = 3600
TabIndex = 1
Top = 1320
Width = 3375
Begin VB.TextBox IDAMOUNT
Height = 285
Left = 1920
TabIndex = 9
Top = 960
Width = 975
End
Begin VB.TextBox IDNO
Height = 285
Left = 1920
TabIndex = 8
Top = 600
Width = 975
End
Begin VB.TextBox IDBLOCKNO
Height = 285
Left = 1920
TabIndex = 7
Top = 240
Width = 975
End
Begin VB.Label Label3
Caption = "anzahl/amount"
Height = 255
Left = 480
TabIndex = 12
Top = 960
Width = 1215
End
Begin VB.Label Label2
Caption = "ab nummer/from no"
Height = 255
Left = 480
TabIndex = 11
Top = 600
Width = 1455
End
Begin VB.Label Label1
Caption = "DB Nr/Datablok "
Height = 255
Left = 480
TabIndex = 10
Top = 240
Width = 1215
End
End
Begin VB.Frame Frame2
Caption = "Wert/value"
Height = 1455
Left = 3600
TabIndex = 0
Top = 2880
Width = 3375
Begin VB.ListBox ID_LIST_VALUE
Height = 1035
Left = 240
TabIndex = 6
Top = 240
Width = 2055
End
Begin VB.OptionButton IDOUTPUT
Caption = "binary"
Height = 255
Index = 2
Left = 2400
TabIndex = 5
Top = 960
Width = 855
End
Begin VB.OptionButton IDOUTPUT
Caption = "decimal"
Height = 255
Index = 1
Left = 2400
TabIndex = 4
Top = 600
Width = 855
End
Begin VB.OptionButton IDOUTPUT
Caption = "hex"
Height = 255
Index = 0
Left = 2400
TabIndex = 3
Top = 240
Width = 855
End
End
Begin VB.Frame Frame4
BackColor = &H00C0C0C0&
Caption = "Verbindung/connection"
Height = 615
Left = 3600
TabIndex = 2
Top = 480
Width = 3375
Begin VB.OptionButton VERB
Caption = "1"
Height = 255
Index = 0
Left = 360
TabIndex = 28
Top = 240
Width = 495
End
Begin VB.OptionButton VERB
Caption = "2"
Height = 255
Index = 1
Left = 840
TabIndex = 27
Top = 240
Width = 495
End
Begin VB.OptionButton VERB
Caption = "3"
Height = 255
Index = 2
Left = 1440
TabIndex = 26
Top = 240
Width = 495
End
Begin VB.OptionButton VERB
Caption = "4"
Height = 255
Index = 3
Left = 2040
TabIndex = 25
Top = 240
Width = 495
End
End
Begin VB.Frame Frame1
Caption = "data type"
Height = 3855
Left = 120
TabIndex = 16
Top = 480
Width = 3375
Begin VB.OptionButton IDDATATYPE
Caption = "Datenbaustein/Datablock"
Height = 255
Index = 7
Left = 360
TabIndex = 24
Top = 3120
Width = 2895
End
Begin VB.OptionButton IDDATATYPE
Caption = "Variablenspeicher/Variable Memory"
Height = 255
Index = 6
Left = 360
TabIndex = 23
Top = 2760
Width = 2895
End
Begin VB.OptionButton IDDATATYPE
Caption = "Sondermerker/Special flag"
Height = 255
Index = 5
Left = 360
TabIndex = 22
Top = 2400
Width = 2895
End
Begin VB.OptionButton IDDATATYPE
Caption = "Z鋒ler/Counter"
Height = 255
Index = 4
Left = 360
TabIndex = 21
Top = 2040
Width = 2895
End
Begin VB.OptionButton IDDATATYPE
Caption = "Timer"
Height = 255
Index = 3
Left = 360
TabIndex = 20
Top = 1680
Width = 2895
End
Begin VB.OptionButton IDDATATYPE
Caption = "Merker/Flag"
Height = 255
Index = 2
Left = 360
TabIndex = 19
Top = 1320
Width = 2895
End
Begin VB.OptionButton IDDATATYPE
Caption = "Ausgang/Output"
Height = 255
Index = 1
Left = 360
TabIndex = 18
Top = 960
Width = 2895
End
Begin VB.OptionButton IDDATATYPE
Caption = "Eingang/Input"
Height = 255
Index = 0
Left = 360
TabIndex = 17
Top = 600
Width = 2895
End
End
End
Attribute VB_Name = "READ_FRM"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub ShowValue()
Dim i, j, k As Long
Dim s As String
Dim s1 As String
ID_LIST_VALUE.Clear
For i = 0 To (AMOUNT - 1)
s = i + no
s = s + ". "
If ((DataTypeIdx = 3) Or (DataTypeIdx = 4)) Then
Select Case OutputTypeIdx
Case 0
s1 = Hex(value_word(i))
Case 1
s1 = value_word(i)
Case 2
j = 1
s1 = ""
While (j < 65536)
k = j And value_word(i)
If (k <> 0) Then
s1 = s1 + "1"
Else
s1 = s1 + "0"
End If
j = j * 2
Wend
End Select
s = s + s1
ID_LIST_VALUE.AddItem (s)
Else
Select Case OutputTypeIdx
Case 0
s1 = Hex(value_byte(i))
Case 1
s1 = value_byte(i)
Case 2
j = 1
s1 = ""
While (j < 256)
k = j And value_byte(i)
If (k <> 0) Then
s1 = s1 + "1"
Else
s1 = s1 + "0"
End If
j = j * 2
Wend
End Select
s = s + s1
ID_LIST_VALUE.AddItem (s)
End If
Next i
End Sub
Private Sub Form_Activate()
VERB(VerbIdx).value = True
IDOUTPUT(OutputTypeIdx).value = True
IDDATATYPE(DataTypeIdx).value = True
IDBLOCKNO.Text = BLOCKNO
IDNO.Text = no
IDAMOUNT.Text = AMOUNT
End Sub
Private Sub IDAMOUNT_Change()
Dim msg
On Error GoTo error_handler
AMOUNT = IDAMOUNT.Text
Exit Sub
error_handler:
IDAMOUNT.Text = AMOUNT
msg = "value not correct"
MsgBox msg
Resume Next
End Sub
Private Sub IDBLOCKNO_Change()
Dim msg
On Error GoTo error_handler
BLOCKNO = IDBLOCKNO.Text
Exit Sub
error_handler:
IDBLOCKNO.Text = BLOCKNO
msg = "value not correct"
MsgBox msg
Resume Next
End Sub
Private Sub IDCYCLEREAD_Click()
Timer1.Enabled = True
End Sub
Private Sub IDDATATYPE_Click(Index As Integer)
DataTypeIdx = Index
End Sub
Private Sub IDCANCEL_Click()
Timer1.Enabled = False
READ_FRM.Visible = False
End Sub
Private Sub IDDATATYPE_LostFocus(Index As Integer)
Timer1.Enabled = False
End Sub
Private Sub IDNO_Change()
Dim msg
On Error GoTo error_handler
no = IDNO.Text
Exit Sub
error_handler:
IDNO.Text = no
msg = "value not correct"
MsgBox msg
Resume Next
End Sub
Private Sub IDOUTPUT_Click(Index As Integer)
OutputTypeIdx = Index
Call ShowValue
End Sub
Private Sub IDREAD_Click()
Dim i, j, k As Long
Dim s As String
Dim s1 As String
Rem Timer1.Enabled = False
If (AMOUNT > 512) Then AMOUNT = 512
res = new_ss(VerbIdx + 1)
If (res = 0) Then
Select Case DataTypeIdx
Case 0
#If S7_200 Then
res = as200_e_field_read(no, AMOUNT, value_byte(0))
#End If
#If S7_300 Then
res = e_field_read(no, AMOUNT, value_byte(0))
#End If
Case 1
#If S7_200 Then
res = as200_a_field_read(no, AMOUNT, value_byte(0))
#End If
#If S7_300 Then
res = a_field_read(no, AMOUNT, value_byte(0))
#End If
Case 2
#If S7_200 Then
res = as200_m_field_read(no, AMOUNT, value_byte(0))
#End If
#If S7_300 Then
res = m_field_read(no, AMOUNT, value_byte(0))
#End If
Case 3
#If S7_200 Then
res = as200_t_field_read(no, AMOUNT, value_word(0))
#End If
#If S7_300 Then
res = t_field_read(no, AMOUNT, value_word(0))
Call swab_buffer(value_word(0), 512)
#End If
Case 4
#If S7_200 Then
res = as200_z_field_read(no, AMOUNT, value_word(0))
#End If
#If S7_300 Then
res = z_field_read(no, AMOUNT, value_word(0))
Call swab_buffer(value_word(0), 512)
#End If
Case 5
#If S7_200 Then
res = as200_sm_field_read(no, AMOUNT, value_byte(0))
#End If
#If S7_300 Then
res = 33028
#End If
Case 6
#If S7_200 Then
res = as200_vs_field_read(no, AMOUNT, value_byte(0))
#End If
#If S7_300 Then
res = 33028
#End If
Case 7
#If S7_200 Then
res = 33028
#End If
#If S7_300 Then
res = d_field_read(BLOCKNO, no, AMOUNT, value_byte(0))
#End If
End Select
End If
If (res = 0) Then
Call ShowValue
End If
If (res <> 0) Then
ERROR_FRM.Show 1, Me
Timer1.Enabled = False
End If
End Sub
Private Sub Timer1_Timer()
Call IDREAD_Click
End Sub
Private Sub VERB_Click(Index As Integer)
VerbIdx = Index
Timer1.Enabled = False
ID_LIST_VALUE.Clear
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -