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

📄 addressdlg.frm

📁 PLC相关-656M.zip
💻 FRM
字号:
VERSION 5.00
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.2#0"; "COMCTL32.OCX"
Begin VB.Form AddressDlg 
   Caption         =   "Addresses"
   ClientHeight    =   4215
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6750
   LinkTopic       =   "Form1"
   ScaleHeight     =   4215
   ScaleWidth      =   6750
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox LogAdd 
      Height          =   285
      Left            =   1440
      TabIndex        =   1
      Top             =   2520
      Width           =   1695
   End
   Begin VB.CommandButton UpdateBtn 
      Caption         =   "Update"
      Default         =   -1  'True
      Height          =   375
      Left            =   1800
      TabIndex        =   8
      Top             =   3720
      Width           =   1455
   End
   Begin VB.CommandButton CloseBtn 
      Cancel          =   -1  'True
      Caption         =   "Close"
      Height          =   375
      Left            =   120
      TabIndex        =   7
      Top             =   3720
      Width           =   1455
   End
   Begin VB.TextBox BitAdd 
      Height          =   285
      Left            =   4920
      TabIndex        =   6
      Top             =   3240
      Width           =   1695
   End
   Begin VB.TextBox Area 
      Height          =   285
      Left            =   4920
      TabIndex        =   5
      Top             =   2880
      Width           =   1695
   End
   Begin VB.TextBox ParPro 
      Height          =   285
      Left            =   4920
      TabIndex        =   4
      Top             =   2520
      Width           =   1695
   End
   Begin VB.TextBox Length 
      Height          =   285
      Left            =   1440
      TabIndex        =   3
      Top             =   3240
      Width           =   1695
   End
   Begin VB.TextBox SubAdd 
      Height          =   285
      Left            =   1440
      TabIndex        =   2
      Top             =   2880
      Width           =   1695
   End
   Begin ComctlLib.ListView AddressList 
      Height          =   2175
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6495
      _ExtentX        =   11456
      _ExtentY        =   3836
      View            =   3
      LabelEdit       =   1
      LabelWrap       =   -1  'True
      HideSelection   =   0   'False
      _Version        =   327682
      ForeColor       =   -2147483640
      BackColor       =   -2147483643
      Appearance      =   1
      NumItems        =   6
      BeginProperty ColumnHeader(1) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "LogicalAddress"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(2) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         SubItemIndex    =   1
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "SubAddress"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(3) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         SubItemIndex    =   2
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Length"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(4) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         SubItemIndex    =   3
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "PartProcessImage"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(5) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         SubItemIndex    =   4
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "Area"
         Object.Width           =   2540
      EndProperty
      BeginProperty ColumnHeader(6) {0713E8C7-850A-101B-AFC0-4210102A8DA7} 
         SubItemIndex    =   5
         Key             =   ""
         Object.Tag             =   ""
         Text            =   "BitAddress"
         Object.Width           =   2540
      EndProperty
   End
   Begin VB.Label Label6 
      Caption         =   "BitAddress"
      Height          =   255
      Left            =   3360
      TabIndex        =   14
      Top             =   3240
      Width           =   1335
   End
   Begin VB.Label Label5 
      Caption         =   "Area"
      Height          =   255
      Left            =   3360
      TabIndex        =   13
      Top             =   2880
      Width           =   855
   End
   Begin VB.Label Label4 
      Caption         =   "PartProcessImage"
      Height          =   255
      Left            =   3360
      TabIndex        =   12
      Top             =   2520
      Width           =   1335
   End
   Begin VB.Label Label3 
      Caption         =   "Length"
      Height          =   255
      Left            =   120
      TabIndex        =   11
      Top             =   3240
      Width           =   855
   End
   Begin VB.Label Label2 
      Caption         =   "SubAddress"
      Height          =   255
      Left            =   120
      TabIndex        =   10
      Top             =   2880
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "LogicalAddress"
      Height          =   255
      Left            =   120
      TabIndex        =   9
      Top             =   2520
      Width           =   1215
   End
End
Attribute VB_Name = "AddressDlg"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Public Adds As S7Addresses

Private curAdd As S7Address
Private curkey As String


Private Function GetKey(add As S7Address) As String
    GetKey = "key" & add.Area & "S" & add.BitAddress & _
             "S" & add.Length & "S" & add.LogicalAddress & "S" & _
             add.PartProcessImage & "S" & add.SubAddress
End Function


Private Function GetAddress(ByRef add As S7Address) As Boolean
    GetAddress = False
    If AddressList.ListItems.count = 0 Then Exit Function
    
    Dim item As ListItem
    Set item = AddressList.SelectedItem
    
    For Each add In Adds
        If GetKey(add) = item.key Then Exit For
    Next
    
    If GetKey(add) <> item.key Then
        UpdateList
        MsgBox "Die Liste wurde auf den neuesten Stand gebracht."
        curkey = ""
        Set curAdd = Nothing
    Else
        GetAddress = True
    End If
End Function


Private Sub AddressList_Click()
    UpdateEditData
End Sub

Private Sub AddressList_KeyUp(keycode As Integer, shift As Integer)
    UpdateEditData
End Sub


Private Sub CloseBtn_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    'Init Layout
    Dim w As Integer
    w = AddressList.Width / 9
    AddressList.ColumnHeaders(1).Width = w
    AddressList.ColumnHeaders(2).Width = w
    AddressList.ColumnHeaders(3).Width = w
    AddressList.ColumnHeaders(4).Width = w
    AddressList.ColumnHeaders(5).Width = w
    AddressList.ColumnHeaders(6).Width = w
    
    UpdateList
    UpdateEditData
End Sub


Private Sub UpdateList()
    Dim add As S7Address
    Dim key As String
    Dim item As ListItem
    
    AddressList.ListItems.Clear
    
    For Each add In Adds
        key = GetKey(add)
        Set item = AddressList.ListItems.add(, key, add.LogicalAddress)
        Call UpdateAddress(add, key)
    Next
End Sub


Private Sub UpdateAddress(add As S7Address, ByRef key As String)
    Dim item As ListItem
    Set item = AddressList.ListItems(key)
    
    item.Text = add.LogicalAddress
    item.SubItems(1) = add.SubAddress
    item.SubItems(2) = add.Length
    item.SubItems(3) = add.PartProcessImage
    item.SubItems(4) = add.Area
    item.SubItems(5) = add.BitAddress
    
    item.key = GetKey(add)
    key = item.key
End Sub


Private Sub UpdateBtn_Click()
On Error GoTo Error1:
    curAdd.LogicalAddress = LogAdd.Text
    curAdd.SubAddress = SubAdd.Text
    curAdd.Length = Length.Text
    curAdd.PartProcessImage = ParPro.Text
    curAdd.Area = Area.Text
    curAdd.BitAddress = BitAdd.Text
    
    Call UpdateAddress(curAdd, curkey)
    
Error1:
    CatchError (True)
End Sub


Private Sub UpdateEditData()
    Dim add As S7Address
    
    If Not GetAddress(add) Then
        curkey = ""
        Set curAdd = Nothing
    Else
        Set curAdd = add
        curkey = GetKey(curAdd)
        
        LogAdd.Text = add.LogicalAddress
        SubAdd.Text = add.SubAddress
        Length.Text = add.Length
        ParPro.Text = add.PartProcessImage
        Area.Text = add.Area
        BitAdd.Text = add.BitAddress
    End If
End Sub

⌨️ 快捷键说明

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