VERSION 5.00
Begin VB.Form Form1 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "门锁制卡"
   ClientHeight    =   7320
   ClientLeft      =   135
   ClientTop       =   1890
   ClientWidth     =   8115
   Icon            =   "demo.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   7320
   ScaleWidth      =   8115
   StartUpPosition =   1  '所有者中心
   Begin VB.TextBox Text_fk 
      Height          =   375
      Left            =   6000
      TabIndex        =   31
      Text            =   "Text_fk"
      Top             =   120
      Visible         =   0   'False
      Width           =   1335
   End
   Begin VB.TextBox Text_zt 
      Height          =   375
      Left            =   4560
      TabIndex        =   29
      Text            =   "Text_zt"
      Top             =   120
      Visible         =   0   'False
      Width           =   1095
   End
   Begin VB.CommandButton Command1 
      Caption         =   "打开串口"
      Height          =   615
      Left            =   2640
      TabIndex        =   3
      Top             =   960
      Width           =   1455
   End
   Begin VB.ComboBox Combo1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   315
      Left            =   720
      TabIndex        =   1
      Text            =   "Combo1"
      Top             =   1080
      Width           =   1695
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2040
      TabIndex        =   0
      Top             =   120
      Width           =   2295
   End
   Begin VB.Frame Frame1 
      Caption         =   "接口函数内容"
      Height          =   6495
      Left            =   120
      TabIndex        =   4
      Top             =   720
      Width           =   7935
      Begin VB.Frame Frame3 
         Caption         =   "信息"
         Height          =   5295
         Left            =   120
         TabIndex        =   6
         Top             =   960
         Width           =   7695
         Begin VB.OptionButton Option2 
            Caption         =   "小时"
            Height          =   255
            Left            =   4800
            TabIndex        =   36
            Top             =   1800
            Width           =   855
         End
         Begin VB.OptionButton Option1 
            Caption         =   "天数"
            Height          =   255
            Left            =   3720
            TabIndex        =   35
            Top             =   1800
            Value           =   -1  'True
            Width           =   855
         End
         Begin VB.ComboBox Combo2 
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   315
            Left            =   1200
            TabIndex        =   34
            Text            =   "Combo2"
            Top             =   1770
            Width           =   2295
         End
         Begin VB.ComboBox Text7 
            Height          =   300
            ItemData        =   "demo.frx":038A
            Left            =   1200
            List            =   "demo.frx":038C
            TabIndex        =   32
            Text            =   "Text7"
            Top             =   3690
            Width           =   2295
         End
         Begin VB.CommandButton Command4 
            Caption         =   "退客人卡"
            Height          =   375
            Left            =   4080
            TabIndex        =   30
            Top             =   4553
            Width           =   1215
         End
         Begin VB.CommandButton Command6 
            Caption         =   "读客人卡"
            Height          =   360
            Left            =   2520
            TabIndex        =   26
            Top             =   4560
            Width           =   1200
         End
         Begin VB.CommandButton Command3 
            Caption         =   "退出"
            Height          =   360
            Left            =   5640
            TabIndex        =   25
            Top             =   4560
            Width           =   1200
         End
         Begin VB.TextBox Text6 
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1200
            TabIndex        =   17
            Text            =   "02"
            Top             =   3180
            Width           =   2295
         End
         Begin VB.TextBox Text5 
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1200
            TabIndex        =   15
            Text            =   "000001"
            Top             =   2700
            Width           =   2295
         End
         Begin VB.TextBox Text4 
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1200
            TabIndex        =   13
            Top             =   2220
            Width           =   2295
         End
         Begin VB.TextBox Text3 
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1200
            TabIndex        =   11
            Top             =   1260
            Width           =   2295
         End
         Begin VB.TextBox Text2 
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   1200
            TabIndex        =   9
            Text            =   "0001"
            Top             =   780
            Width           =   2295
         End
         Begin VB.CommandButton Command5 
            Caption         =   "写客人卡"
            Height          =   360
            Left            =   960
            TabIndex        =   7
            Top             =   4560
            Width           =   1200
         End
         Begin VB.Label Label16 
            Caption         =   "为4位或6位长，普通房间为4位，子房间为6位"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3840
            TabIndex        =   37
            Top             =   480
            Visible         =   0   'False
            Width           =   3975
         End
         Begin VB.Label Label15 
            Alignment       =   1  'Right Justify
            Caption         =   "预住天数:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   33
            Top             =   1740
            Width           =   975
         End
         Begin VB.Label Label_ftbh 
            AutoSize        =   -1  'True
            Caption         =   "Label_ftbh"
            Height          =   180
            Left            =   1200
            TabIndex        =   28
            Top             =   360
            Width           =   900
         End
         Begin VB.Label Label14 
            AutoSize        =   -1  'True
            Caption         =   "房间号码:"
            Height          =   180
            Left            =   360
            TabIndex        =   27
            Top             =   360
            Width           =   810
         End
         Begin VB.Label Label13 
            Caption         =   "16进制，6位长，每张卡唯一标志，可顺序加1"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3600
            TabIndex        =   24
            Top             =   2760
            Width           =   3615
         End
         Begin VB.Label Label12 
            Caption         =   "2位长"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3600
            TabIndex        =   23
            Top             =   3240
            Width           =   3615
         End
         Begin VB.Label Label11 
            Caption         =   "2位长。01 为能开反锁，00 为不能开反锁"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3600
            TabIndex        =   22
            Top             =   3720
            Width           =   3615
         End
         Begin VB.Label Label10 
            Caption         =   "格式为yyyymmddhhmm，为12长"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3600
            TabIndex        =   21
            Top             =   2280
            Width           =   3975
         End
         Begin VB.Label Label9 
            Caption         =   "格式为yyyymmddhhmm，为12位长"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3600
            TabIndex        =   20
            Top             =   1320
            Width           =   3975
         End
         Begin VB.Label Label8 
            Caption         =   "门锁编号长度为4位或6位"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            ForeColor       =   &H000000FF&
            Height          =   255
            Left            =   3600
            TabIndex        =   19
            Top             =   840
            Width           =   3975
         End
         Begin VB.Label Label7 
            Alignment       =   1  'Right Justify
            Caption         =   "反锁标志:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   18
            Top             =   3660
            Width           =   975
         End
         Begin VB.Label Label6 
            Alignment       =   1  'Right Justify
            Caption         =   "卡号:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   16
            Top             =   3180
            Width           =   975
         End
         Begin VB.Label Label5 
            Alignment       =   1  'Right Justify
            Caption         =   "卡系列号:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   14
            Top             =   2700
            Width           =   975
         End
         Begin VB.Label Label4 
            Alignment       =   1  'Right Justify
            Caption         =   "结束时间:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   12
            Top             =   2220
            Width           =   975
         End
         Begin VB.Label Label3 
            Alignment       =   1  'Right Justify
            Caption         =   "开始时间:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   10
            Top             =   1260
            Width           =   975
         End
         Begin VB.Label Label1 
            Alignment       =   1  'Right Justify
            Caption         =   "门锁编号:"
            BeginProperty Font 
               Name            =   "MS Sans Serif"
               Size            =   9.75
               Charset         =   0
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   375
            Left            =   120
            TabIndex        =   8
            Top             =   780
            Width           =   975
         End
      End
      Begin VB.CommandButton Command2 
         Caption         =   "关闭串口"
         Height          =   615
         Left            =   3960
         TabIndex        =   5
         Top             =   240
         Width           =   1455
      End
   End
   Begin VB.Label Label2 
      Alignment       =   1  'Right Justify
      Caption         =   "接口函数注册号:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   360
      TabIndex        =   2
      Top             =   120
      Width           =   1575
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim com As Integer
Dim IniF As CIniFile

Private Sub Combo2_Change()
Dim ts As Integer
Dim strbegdate, strbegtime
Dim strenddate, strendtime
ts = Int(Combo2.Text)
'If Option2.Value = True Then ts = ts / 24
strbegdate = Format(Date, "yyyymmdd")
strbegtime = Format(Time, "hhmm")
strenddate = Format(DateAdd("d", ts, Date), "yyyymmdd")
strendtime = Format(DateAdd("h", ts, Time), "hhmm")
Text3.Text = strbegdate & strbegtime
If Option2.Value = True Then
  Text4.Text = strbegdate & strendtime '
End If
If Option1.Value = True Then
  Text4.Text = strenddate & "1400"   'strbegtime
End If
Text5.Text = "00" & strbegtime
End Sub

Private Sub Combo2_Click()
Dim ts As Integer
Dim strbegdate, strbegtime
Dim strenddate, strendtime
ts = Int(Combo2.Text)
'If Option2.Value = True Then ts = ts / 24
strbegdate = Format(Date, "yyyymmdd")
strbegtime = Format(Time, "hhmm")
strenddate = Format(DateAdd("d", ts, Date), "yyyymmdd")
strendtime = Format(DateAdd("h", ts, Time), "hhmm")
Text3.Text = strbegdate & strbegtime
If Option2.Value = True Then
  Text4.Text = strbegdate & strendtime '
End If
If Option1.Value = True Then
  Text4.Text = strenddate & "1400"   'strbegtime
End If
Text5.Text = "00" & strbegtime
End Sub

Private Sub Combo2_KeyDown(KeyCode As Integer, Shift As Integer)
key = 0
End Sub

Private Sub Combo2_KeyPress(KeyAscii As Integer)
key = 0
End Sub

Private Sub Command1_Click()
'打开串口
    Dim i As Integer
    
    If (Trim(Combo1.Text) = "串口一") Then
      com = 0
    ElseIf (Trim(Combo1.Text) = "串口二") Then
      com = 1
    ElseIf (Trim(Combo1.Text) = "串口三") Then
      com = 2
    ElseIf (Trim(Combo1.Text) = "串口四") Then
      com = 3
    End If
 
    i = opencomm(com)
    If i <> 0 Then
        MsgBox "无法打开串口！", 0, "opencomm错误"
    Else
        MsgBox "打开串口成功！", 0, "opencomm成功"
    End If


End Sub

Private Sub Command2_Click()
'关闭串口
 Dim i As Integer
 i = closecomm()
 If i <> 0 Then
    MsgBox "无法关闭串口！", 0, "closecomm 错误"
 Else
    MsgBox "关闭串口成功！", 0, "closecomm 成功"
 End If
End Sub

Private Sub Command3_Click()
'退客人卡
 Dim i As Integer
 IniF.WriteString "fk", "发卡", "F"   '写入发卡成功
 'i = closecomm()
 Unload Me
End
End Sub

Private Sub Command4_Click()
  Dim i As Integer
  Dim cardserialnum As String
  cardserialnum = Trim(Text1.Text)
  i = deletecard(cardserialnum)
  If i <> 0 Then
    MsgBox "退客人卡失败！", 0, "deletecard 错误"
  Else
    MsgBox "退客人卡成功！", 0, "deletecard 成功"
    IniF.WriteString "fk", "发卡", "T"   '写入发卡成功
    Unload Me
  End If
End Sub

Private Sub Command5_Click()
'写客人卡
  Dim i As Integer
  Dim j As Integer
  Dim roomnum As String
  Dim begdate As String
  Dim enddate As String
  Dim cardid As String
  Dim fansuostatus As String
  Dim cardserialnum As String
  Dim regserialnum As String
  
  If Len(Trim(Text1.Text)) <> 11 Then
     MsgBox "接口函数注册号输入错误！", 0, "错误"
     Text1.SetFocus
     Exit Sub
  Else
     regserialnum = Trim(Text1.Text)
  End If
  
  If Len(Trim(Text2.Text)) <> 4 And Len(Trim(Text2.Text)) <> 6 Then
     MsgBox "房间号码输入错误！", 0, "错误"
     Text2.SetFocus
     Exit Sub
  Else
     roomnum = Trim(Text2.Text)
  End If
  
  If Len(Trim(Text3.Text)) <> 12 Then
     MsgBox "开始时间输入错误！", 0, "错误"
     Text3.SetFocus
     Exit Sub
  Else
     begdate = Trim(Text3.Text)
  End If
  
  If Len(Trim(Text4.Text)) <> 12 Then
     MsgBox "结束时间输入错误！", 0, "错误"
     Text4.SetFocus
     Exit Sub
  Else
     enddate = Trim(Text4.Text)
  End If
  
  If Len(Trim(Text5.Text)) <> 6 Then
     MsgBox "卡系列号输入错误！", 0, "错误"
     Text5.SetFocus
     Exit Sub
  Else
     cardserialnum = Trim(Text5.Text)
  End If
  
  If Len(Trim(Text6.Text)) <> 2 Then
     MsgBox "卡号输入错误！", 0, "错误"
     Text6.SetFocus
     Exit Sub
  Else
     cardid = Trim(Text6.Text)
  End If
  
  If Len(Trim(Text7.Text)) <> 2 Then
     MsgBox "反锁标志输入错误！", 0, "错误"
     Text7.SetFocus
     Exit Sub
  Else
     fansuostatus = Trim(Text7.Text)
  End If
  
  i = makecard(roomnum, begdate, enddate, fansuostatus, cardid, cardserialnum, regserialnum)
  If i <> 0 Then
    MsgBox "制客人卡失败！", 0, "makecard 错误"
  Else
    MsgBox "制客人卡成功！", 0, "makecard 成功"
    IniF.WriteString "fk", "发卡", "T"   '写入发卡成功
    Unload Me
  End If
End Sub

Private Sub Command6_Click()
'读客人卡
  Dim i As Integer
  Dim carddata As String * 64
  Dim regserialnum As String
  Dim position As Integer
  Dim st As String
  If Len(Trim(Text1.Text)) <> 11 Then
     MsgBox "接口函数注册号输入错误！", 0, "错误"
     Text1.SetFocus
     Exit Sub
  Else
     regserialnum = Trim(Text1.Text)
  End If
  Text2.Text = ""
  Text3.Text = ""
  Text4.Text = ""
  Text5.Text = ""
  Text6.Text = ""
  Text7.Text = ""
  i = readcard(carddata, regserialnum)
  If i <> 0 Then
    MsgBox "读客人卡失败！", 0, "makecard 错误"
    Exit Sub
  Else
    MsgBox "读客人卡成功！", 0, "makecard 成功"
  End If
  
  st = Mid(carddata, 7, 6)
  position = InStr(5, st, "00")
  If position > 0 Then
  Text2.Text = Mid(st, 1, 4)
  End If
  Text3.Text = Mid(carddata, 14, 12)
  Text4.Text = Mid(carddata, 27, 12)
  Text5.Text = Mid(carddata, 40, 6)
  Text6.Text = Mid(carddata, 1, 2)
  Text7.Text = Mid(carddata, 4, 2)
  
  'Set IniF = New CIniFile
  'IniF.SpecifyIni (App.Path + "\..\MSJK\msjk.ini")
  'IniF.WriteString("ftbh", "房台编号", Text2.Text) = True
  'IniF.WriteString("msbh", "门锁编号", Text2.Text) = True
  'IniF.WriteString("fk", "发卡", "T") = True
  
  'Unload Me
End Sub
Private Sub Form_Load()
Dim strbegdate, strbegtime
Dim strenddate, strendtime
Dim strts As String
Dim ts As Integer
Dim its As Integer

Text1.Text = "30055057104"
Combo1.AddItem "串口一"
Combo1.AddItem "串口二"
Combo1.AddItem "串口三"
Combo1.AddItem "串口四"
Combo1.Text = "串口一"
Text7.AddItem "01"
Text7.AddItem "00"
Text7.Text = "01"

Set IniF = New CIniFile
IniF.SpecifyIni (App.Path + "\..\MSJK\msjk.ini")
Label_ftbh.Caption = Trim(IniF.ReadString("ftbh", "房台编号", 8))
Text2.Text = Trim(IniF.ReadString("msbh", "门锁编号", 16))
Text_zt.Text = Trim(IniF.ReadString("zt", "状态", 4))
Text_fk.Text = Trim(IniF.ReadString("fk", "发卡", 4))
strts = Trim(IniF.ReadString("ts", "天数", 4))
If strts = "" Then strts = "1"
ts = Int(strts)
For its = 1 To 90
  Combo2.AddItem CStr(its)
  Next its
Combo2.Text = strts

'If Option2.Value = True Then ts = ts / 24
Combo1.Text = Trim(IniF.ReadString("ckh", "串口号", 8))
If Combo1.Text = "" Then Combo1.Text = "串口一"

strbegdate = Format(Date, "yyyymmdd")
strbegtime = Format(Time, "hhmm")
strenddate = Format(DateAdd("d", ts, Date), "yyyymmdd")
strendtime = Format(DateAdd("h", ts, Time), "hhmm")
Text3.Text = strbegdate & strbegtime
If Option2.Value = True Then
  Text4.Text = strbegdate & strendtime '
End If
If Option1.Value = True Then
  Text4.Text = strenddate & "1400"   'strbegtime
End If
Text5.Text = "00" & strbegtime

Form1.Caption = "门禁写卡程序"
Command5.Visible = True
Command6.Visible = True
Command4.Visible = True
If Text_zt.Text = "KD" Then
  Form1.Caption = "门禁发卡"
  Command5.Visible = True
  Command6.Visible = True
  Command4.Visible = False
End If
If Text_zt.Text = "DK" Then
  Form1.Caption = "门禁快速读卡"
  Command5.Visible = False
  Command6.Visible = True
  Command4.Visible = False
End If
If Text_zt.Text = "JZ" Then
  Form1.Caption = "门禁退卡"
  Command5.Visible = False
  Command6.Visible = True
  Command4.Visible = True
End If

If (Trim(Combo1.Text) = "串口一") Then
  com = 0
ElseIf (Trim(Combo1.Text) = "串口二") Then
  com = 1
ElseIf (Trim(Combo1.Text) = "串口三") Then
  com = 2
ElseIf (Trim(Combo1.Text) = "串口四") Then
  com = 3
End If
 
i = opencomm(com)
If i <> 0 Then
  MsgBox "无法打开串口！", 0, "opencomm错误"
'Else
  'MsgBox "打开串口成功！", 0, "opencomm成功"
End If

If Form1.Caption = "门禁快速读卡" Then
 '读客人卡
  Dim carddata As String * 64
  Dim regserialnum As String
  Dim position As Integer
  Dim st As String
  If Len(Trim(Text1.Text)) <> 11 Then
     MsgBox "接口函数注册号输入错误！", 0, "错误"
     Text1.SetFocus
     Exit Sub
  Else
     regserialnum = Trim(Text1.Text)
  End If
  Text2.Text = ""
  Text3.Text = ""
  Text4.Text = ""
  Text5.Text = ""
  Text6.Text = ""
  Text7.Text = ""
  i = readcard(carddata, regserialnum)
  If i <> 0 Then
    MsgBox "读客人卡失败！", 0, "makecard 错误"
    Exit Sub
  Else
    MsgBox "读客人卡成功！", 0, "makecard 成功"
  End If
  
  st = Mid(carddata, 7, 6)
  position = InStr(5, st, "00")
  If position > 0 Then
  Text2.Text = Mid(st, 1, 4)
  End If
  Text3.Text = Mid(carddata, 14, 12)
  Text4.Text = Mid(carddata, 27, 12)
  Text5.Text = Mid(carddata, 40, 6)
  Text6.Text = Mid(carddata, 1, 2)
  Text7.Text = Mid(carddata, 4, 2)
  
  Set IniF = New CIniFile
  IniF.SpecifyIni (App.Path + "\..\MSJK\msjk.ini")
  IniF.WriteString "ftbh", "房台编号", Text2.Text
  IniF.WriteString "msbh", "门锁编号", Text2.Text
  IniF.WriteString "fk", "发卡", "T"

  Unload Me
End If
  End
End Sub

Private Sub Option1_Click()
Dim ts As Integer
Dim strbegdate, strbegtime
Dim strenddate, strendtime
ts = Int(Combo2.Text)
strbegdate = Format(Date, "yyyymmdd")
strbegtime = Format(Time, "hhmm")
strenddate = Format(DateAdd("d", ts, Date), "yyyymmdd")
strendtime = Format(DateAdd("h", ts, Time), "hhmm")
Text3.Text = strbegdate & strbegtime
If Option2.Value = True Then
  Text4.Text = strbegdate & strendtime '
End If
If Option1.Value = True Then
  Text4.Text = strenddate & "1400"   'strbegtime
End If
Text5.Text = "00" & strbegtime
End Sub

Private Sub Option2_Click()
Dim ts As Integer
Dim strbegdate, strbegtime
Dim strenddate, strendtime
ts = Int(Combo2.Text)
'ts = ts / 24
strbegdate = Format(Date, "yyyymmdd")
strbegtime = Format(Time, "hhmm")
strenddate = Format(DateAdd("d", ts, Date), "yyyymmdd")
strendtime = Format(DateAdd("h", ts, Time), "hhmm")
Text3.Text = strbegdate & strbegtime
If Option2.Value = True Then
  Text4.Text = strbegdate & strendtime '
End If
If Option1.Value = True Then
  Text4.Text = strenddate & "1400"   'strbegtime
End If
Text5.Text = "00" & strbegtime
End Sub
