VERSION 5.00
Begin VB.Form frmPacketStructure 
   Caption         =   "Packet Structure"
   ClientHeight    =   1590
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   11580
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1590
   ScaleWidth      =   11580
   StartUpPosition =   1  '家蜡磊 啊款单
   Begin VB.CommandButton cmdClose 
      Caption         =   "Close"
      Height          =   465
      Left            =   10350
      TabIndex        =   23
      Top             =   675
      Width           =   1095
   End
   Begin VB.CommandButton cmdConvert 
      Caption         =   "Convert"
      Height          =   465
      Left            =   10350
      TabIndex        =   22
      Top             =   90
      Width           =   1095
   End
   Begin VB.TextBox txtBinETX 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   9630
      TabIndex        =   21
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinBCC 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   9000
      TabIndex        =   20
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinData5 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   8370
      TabIndex        =   19
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinData4 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   7740
      TabIndex        =   18
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinData3 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   7155
      TabIndex        =   17
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinData2 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   6570
      TabIndex        =   16
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinData1 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   5940
      TabIndex        =   15
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinCommand3 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   5355
      TabIndex        =   14
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinCommand2 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   4770
      TabIndex        =   13
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinCommand1 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   4140
      TabIndex        =   12
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBinAttribute 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   3330
      TabIndex        =   11
      Top             =   630
      Width           =   735
   End
   Begin VB.TextBox txtBinID 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   2520
      TabIndex        =   10
      Top             =   630
      Width           =   735
   End
   Begin VB.TextBox txtBinSTX 
      Alignment       =   2  '啊款单 嘎勉
      Height          =   375
      Left            =   1845
      TabIndex        =   9
      Top             =   630
      Width           =   600
   End
   Begin VB.TextBox txtBCC 
      Height          =   330
      Left            =   9000
      TabIndex        =   7
      Top             =   180
      Width           =   600
   End
   Begin VB.TextBox txtData 
      Height          =   330
      Left            =   5940
      TabIndex        =   6
      Top             =   180
      Width           =   3030
   End
   Begin VB.ComboBox cbCommand 
      Height          =   300
      Left            =   4140
      TabIndex        =   5
      Top             =   195
      Width           =   1770
   End
   Begin VB.ComboBox cbAttribute 
      Height          =   300
      Left            =   3330
      TabIndex        =   4
      Top             =   195
      Width           =   780
   End
   Begin VB.ComboBox cbID 
      Height          =   300
      Left            =   2520
      TabIndex        =   3
      Top             =   195
      Width           =   780
   End
   Begin VB.Label Label3 
      Caption         =   "BCC Check Area"
      ForeColor       =   &H00FF0000&
      Height          =   240
      Left            =   5130
      TabIndex        =   24
      Top             =   1350
      Width           =   1545
   End
   Begin VB.Image Image1 
      Height          =   300
      Left            =   2610
      Picture         =   "frmPacketStructure.frx":0000
      Stretch         =   -1  'True
      Top             =   1080
      Width           =   6375
   End
   Begin VB.Line Line1 
      Index           =   1
      X1              =   9000
      X2              =   9000
      Y1              =   1125
      Y2              =   1575
   End
   Begin VB.Line Line1 
      Index           =   0
      X1              =   2520
      X2              =   2520
      Y1              =   1125
      Y2              =   1575
   End
   Begin VB.Label Label2 
      Caption         =   "[ETX]"
      ForeColor       =   &H00FF0000&
      Height          =   240
      Index           =   1
      Left            =   9630
      TabIndex        =   8
      Top             =   270
      Width           =   555
   End
   Begin VB.Label Label2 
      Caption         =   "[STX]"
      ForeColor       =   &H00FF0000&
      Height          =   240
      Index           =   0
      Left            =   1845
      TabIndex        =   2
      Top             =   225
      Width           =   555
   End
   Begin VB.Label Label1 
      Caption         =   "Packet BINARY"
      ForeColor       =   &H000000FF&
      Height          =   240
      Index           =   1
      Left            =   90
      TabIndex        =   1
      Top             =   675
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "Packet ASCII"
      ForeColor       =   &H000000FF&
      Height          =   240
      Index           =   0
      Left            =   90
      TabIndex        =   0
      Top             =   225
      Width           =   1275
   End
End
Attribute VB_Name = "frmPacketStructure"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'--------------------------------------------
'
'--------------------------------------------
Private Sub Form_Load()
    Dim i As Integer
    
    'Insert ID data to Combobox. If use RS-232, must be set to 0
    For i = 0 To 9
        cbID.AddItem CStr(i)
    Next i
    
    'Insert Attribute $ (Request) or # (Respond)
    cbAttribute.AddItem "$"
    cbAttribute.AddItem "#"
    
    'Insert Command to ComboBox
    Dim CMD
    CMD = Array("SET", "STR", "MDM", "MOR", "MOT", "TGA", "JOG", "SVR", "TAT", "TMN", _
                "STP", "MOV", "MOP", "ORG", "STS", "RTS", "POS", "VER")
    For i = 0 To UBound(CMD, 1)
        cbCommand.AddItem CMD(i)
    Next i
    
    txtBinSTX.Text = "02"
    txtBinETX.Text = "03"
End Sub

'--------------------------------------------
'Close Window
'--------------------------------------------
Private Sub cmdClose_Click()
    Unload Me
End Sub

'--------------------------------------------
'
'--------------------------------------------
Private Sub cmdConvert_Click()

End Sub
'-------------------------------------
'Calc BCC
'After Taking All data included STX ~ ETX,
'Calculate the BCC and return
'-------------------------------------
Private Sub FillBCC()
'Private Sub FillBCC(ByRef RBB() As Byte, ByVal DataLength As Integer)
'    Dim i As Integer
'    Dim BCC As Integer
'    Dim S As String
'
'    For i = 1 To DataLength - 2
'        BCC = BCC + RBB(i)
'    Next
'    S = Right("0000" + CStr(Hex(BCC)), 4)
'    CalcBCC = CByte(Asc(Mid(S, 4, 1)))
End Sub

'--------------------------------------------
'
'--------------------------------------------
Private Sub cbID_Click()
    If cbID.Text = "" Then Exit Sub
    txtBinID.Text = CStr(Hex(Asc(cbID.Text)))
    FillBCC
End Sub

'--------------------------------------------
'
'--------------------------------------------
Private Sub cbAttribute_Click()
    If cbAttribute.Text = "" Then Exit Sub
    txtBinAttribute.Text = CStr(Hex(Asc(cbAttribute.Text)))
    FillBCC
End Sub

'--------------------------------------------
'
'--------------------------------------------
Private Sub cbCommand_Click()
    Dim S As String
    Dim i As Integer
    Dim oControl As Control
    
    If cbCommand.Text = "" Then Exit Sub

'-----------------------------------------
'    i = 1
'    For Each oControl In Controls
'        S = "txtBinCommand" + CStr(i)
'        If Left(oControl.Name, 14) = S Then
'            oControl.Text = CStr(Hex(Asc(Mid(cbCommand.Text, i, 1))))
'            i = i + 1
'        End If
'    Next
'-----------------------------------------
    txtBinCommand1 = CStr(Hex(Asc(Mid(cbCommand.Text, 1, 1))))
    txtBinCommand2 = CStr(Hex(Asc(Mid(cbCommand.Text, 2, 1))))
    txtBinCommand3 = CStr(Hex(Asc(Mid(cbCommand.Text, 3, 1))))
    
    FillBCC
End Sub



'--------------------------------------------
'
'--------------------------------------------

'--------------------------------------------
'
'--------------------------------------------


'--------------------------------------------
'
'--------------------------------------------

'--------------------------------------------
'
'--------------------------------------------

