📄 form_chye.frm
字号:
VERSION 5.00
Object = "{648A5603-2C6E-101B-82B6-000000000014}#1.1#0"; "MSCOMM32.OCX"
Begin VB.Form Form_chye
BorderStyle = 1 'Fixed Single
Caption = "查余额"
ClientHeight = 3720
ClientLeft = 45
ClientTop = 435
ClientWidth = 7635
LinkTopic = "Form4"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3720
ScaleWidth = 7635
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox Text7
Alignment = 1 'Right Justify
BackColor = &H8000000B&
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 2280
Locked = -1 'True
TabIndex = 14
Top = 2880
Width = 1815
End
Begin VB.TextBox Text5
BackColor = &H8000000B&
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 2280
Locked = -1 'True
TabIndex = 12
Top = 1440
Width = 3255
End
Begin VB.TextBox Text4
BackColor = &H8000000B&
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 4920
Locked = -1 'True
TabIndex = 10
Top = 960
Width = 615
End
Begin VB.TextBox Text3
BackColor = &H8000000B&
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 2280
Locked = -1 'True
TabIndex = 8
Top = 960
Width = 1815
End
Begin VB.TextBox Text1
BackColor = &H8000000B&
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 2280
Locked = -1 'True
TabIndex = 2
Top = 1920
Width = 1815
End
Begin VB.TextBox Text2
BackColor = &H8000000B&
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 2280
Locked = -1 'True
TabIndex = 1
Top = 2400
Width = 1815
End
Begin VB.CommandButton Command2
Caption = "退 出"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 405
Left = 4920
TabIndex = 0
Top = 2880
Width = 1455
End
Begin MSCommLib.MSComm MSComm1
Left = 480
Top = 480
_ExtentX = 1005
_ExtentY = 1005
_Version = 393216
DTREnable = -1 'True
End
Begin VB.Label Label13
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "元"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 4200
TabIndex = 16
Top = 3000
Width = 300
End
Begin VB.Label Label12
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "累计消费金额"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 360
TabIndex = 15
Top = 3000
Width = 1800
End
Begin VB.Label Label9
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "性别"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 4200
TabIndex = 13
Top = 1080
Width = 600
End
Begin VB.Label Label5
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "姓名"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 1560
TabIndex = 11
Top = 1080
Width = 600
End
Begin VB.Label Label4
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "身份证号"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 960
TabIndex = 9
Top = 1560
Width = 1200
End
Begin VB.Label Label6
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "查余额"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF0000&
Height = 285
Left = 1200
TabIndex = 7
Top = 360
Width = 900
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "卡余额"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 1200
TabIndex = 6
Top = 2520
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "元"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 4200
TabIndex = 5
Top = 2520
Width = 300
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "卡编号"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 1200
TabIndex = 4
Top = 2040
Width = 900
End
Begin VB.Label Label8
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "请划卡----"
BeginProperty Font
Name = "宋体"
Size = 14.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 2280
TabIndex = 3
Top = 360
Width = 1560
End
End
Attribute VB_Name = "Form_chye"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CardNumber As Double
Dim lianjie As New Connection
Dim yue As Recordset
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
MSComm1.CommPort = com_x '串口号,
MSComm1.Settings = "9600,N,8,1" '串口的属性
MSComm1.InputLen = 0 '接收缓冲区的大小
MSComm1.InputMode = comInputModeBinary '二进制接受方式
MSComm1.RThreshold = 7 '每7个字节响应消息
MSComm1.PortOpen = True '打开通信串口
With lianjie
.ConnectionString = dblianjie
.Open
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
lianjie.Close
Set lianjie = Nothing
If (MSComm1.PortOpen) Then
MSComm1.PortOpen = False
End If
End Sub
Private Sub MSComm1_OnComm()
Select Case MSComm1.CommEvent '串口事件
Case comEvReceive '接收到数据
Dim Buffer As Variant '存储数据的缓冲区
Dim StringBuf(8) As String '数据数组
Buffer = MSComm1.Input '清理接收缓冲区,此时,接收的字节数已经为0
'Dim CardNumber As Long '卡号
CardNumber = CDec(Buffer(3)) * 2 ^ 24 + (Buffer(4) * 2 ^ 16) + (Buffer(5) * 2 ^ 8) + Buffer(6) '单个字节数据左移
'----------------------------------
Set yue = New Recordset
yue.CursorLocation = adUseClient
yue.CursorType = adOpenDynamic
yue.Open "select * from 卡资料 where 卡号='" & CStr(CardNumber) & "'", lianjie
If yue.RecordCount > 0 Then
If Trim(yue.Fields("卡状态")) = "正常" Then
Text1.Text = Trim(yue.Fields("卡编号"))
Text2.Text = Format(yue.Fields("卡余额"), "0.00")
Text3.Text = Trim(yue.Fields("姓名"))
Text4.Text = Trim(yue.Fields("性别"))
Text5.Text = Trim(yue.Fields("身份证号"))
Text7.Text = Format(yue.Fields("累计消费"), "0.00")
Else
If (MSComm1.PortOpen) Then
MSComm1.PortOpen = False
End If
MsgBox "本卡已挂失!", vbExclamation, "读卡提示"
MSComm1.PortOpen = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text7.Text = ""
End If
Else
If (MSComm1.PortOpen) Then
MSComm1.PortOpen = False
End If
MsgBox "非本系统注册的卡!", vbExclamation, "读卡提示"
MSComm1.PortOpen = True
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text7.Text = ""
End If
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -