icdev = auto_init(0, 2400)
If icdev < 0 Then
If MsgBox("设备连接错误,退出后重试", 52, "提示信息:") = vbYes Then
st = ic_exit(icdev)
Else
End If
Else
List1.AddItem ("设备连接 OK")
end if这是第二部分点击读卡
'''''''''''''''''''''''''''''''''''''
10: Dim sss
sss = get_status(icdev, status)
If status = 0 Then
st = ic_exit(icdev)
GoTo 10
Else
st = chk_4442(icdev)
If st <> 0 Then '正确
If MsgBox("未指定卡型,请插入指定卡型,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
'password(0) = &HB6
'password(1) = &H23
'password(2) = &H7
oldpass = "09011f"
st = asc_hex(oldpass, password(0), 3) '十六进制转换
If st < 0 Then
If MsgBox("插卡错误,请插入指定卡型,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
st = csc_4442(icdev, 3, password(0))
If st < 0 Then '卡片指定的密码错误
If MsgBox("卡指定密码错误,请插入指定的卡,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$没调试,计数为 0¥¥¥¥¥¥¥¥¥¥¥¥¥¥
st = rsct_4442(icdev, counter)
If st < 0 Then
If MsgBox("此卡无效,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
If Str(counter) <= 0 Then
If MsgBox("此卡无效,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
End If
'################################ ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
' List1.AddItem ("密码正确")
a = 40
a1 = 6
st = srd_4442(icdev, a, a1, Data1)
If st < 0 Then
If MsgBox("卡读取错误,请仔细确认后点击重试1", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
End If
Else
kahao.Caption = Data1
End If
st = ic_exit(icdev)
Exit Sub
End If
End If
End If
' List1.AddItem ("串口关闭 OK")
End If
End If st = ic_exit(icdev)
GoTo 10
Exit Sub
我只能在第一次读出卡里的数据,第二次则不行,程序完全没响应,有做过读卡程序的朋友吗,能指点一下吗,
还有第一部分如果读取错误必须把整个vb退出才能重新调试,说是串口被占用,
忘高手指点·
If icdev < 0 Then
If MsgBox("设备连接错误,退出后重试", 52, "提示信息:") = vbYes Then
st = ic_exit(icdev)
Else
End If
Else
List1.AddItem ("设备连接 OK")
end if这是第二部分点击读卡
'''''''''''''''''''''''''''''''''''''
10: Dim sss
sss = get_status(icdev, status)
If status = 0 Then
st = ic_exit(icdev)
GoTo 10
Else
st = chk_4442(icdev)
If st <> 0 Then '正确
If MsgBox("未指定卡型,请插入指定卡型,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
'password(0) = &HB6
'password(1) = &H23
'password(2) = &H7
oldpass = "09011f"
st = asc_hex(oldpass, password(0), 3) '十六进制转换
If st < 0 Then
If MsgBox("插卡错误,请插入指定卡型,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
st = csc_4442(icdev, 3, password(0))
If st < 0 Then '卡片指定的密码错误
If MsgBox("卡指定密码错误,请插入指定的卡,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$没调试,计数为 0¥¥¥¥¥¥¥¥¥¥¥¥¥¥
st = rsct_4442(icdev, counter)
If st < 0 Then
If MsgBox("此卡无效,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
If Str(counter) <= 0 Then
If MsgBox("此卡无效,点击重试", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
Exit Sub
End If
Else
End If
'################################ ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥
' List1.AddItem ("密码正确")
a = 40
a1 = 6
st = srd_4442(icdev, a, a1, Data1)
If st < 0 Then
If MsgBox("卡读取错误,请仔细确认后点击重试1", 21, "提示信息:") = vbRetry Then
GoTo 10
Else
st = ic_exit(icdev)
End If
Else
kahao.Caption = Data1
End If
st = ic_exit(icdev)
Exit Sub
End If
End If
End If
' List1.AddItem ("串口关闭 OK")
End If
End If st = ic_exit(icdev)
GoTo 10
Exit Sub
我只能在第一次读出卡里的数据,第二次则不行,程序完全没响应,有做过读卡程序的朋友吗,能指点一下吗,
还有第一部分如果读取错误必须把整个vb退出才能重新调试,说是串口被占用,
忘高手指点·
解决方案 »
- Image控件--处理尺寸不同图片是否用Stretch
- 【寻人启事】UP UP UP UP UP UP UP UP
- 【问】如何区分点击的是系统托盘图标的左或右半部分?
- [&关注&]Adodc1.Recordset.UpdateBatch adAffectCurrent
- 如何释放动态连接库(.dll文件)??
- 请问怎么样在报表上加一个查询啊?(
- ADO 出错
- VB程序设置成系统服务后,为什么启动不了呢?说:在本地无法启动服务,错误1053 服务没有及时响应启动或控制请求
- 请教 关于 My.Computer.Network.DownloadFile 的假死 跟 form1跟 form2连接的问题
- 一个不算太难的问题
- ActiveReport 回复空值行的问题
- vb 关于MSFlexGrid1
应该是打开Com1口,一般来说波特率不正确可能会产生你描述的问题,常用的有9600,19200,这个需要核实开发文档
sss = get_status(icdev, status) 时应该保证Icdev的值大于0,并且确实是最近一次打开的串口句柄号
一开是用的是9600的端口,但测试多了后就没用了,只能用2400的,也不知道为啥,我想这和程序没多大的冲突。
问题是 1.怎么释放串口(可以肯定串口打开了。但怎么关闭串口呢,试了不少都没用,只能把vb退出才能释放,不可能我每读一次都要关闭程序吧!) 2.串口不关闭,怎么才能进行第二次读取(在串口不关比的情况下,点击第二部分代码第一次读取是没问题。第二次直接没响应,WHY??)
你确定执行了 ic_exit 之后仍然无法关闭串口吗?那就似乎是你的 DLL 有问题。icdev = auto_init(0, 2400)
If icdev < 0 Then
st = ic_exit(icdev)
MsgBox "设备连接错误,退出后重试", , "提示信息:"
End
Exit Sub
End IfList1.AddItem ("设备连接 OK")2.
代码写的很乱。Call get_status(icdev, status)
If status = 0 Then
MsgBox "请插入卡片后重新读卡。"
Exit Sub
End Ifst = chk_4442(icdev)
If st <> 0 Then '正确
MsgBox "未指定卡型,请插入指定卡型,点击重试", , "提示信息:"
Exit Sub
End Ifoldpass = "09011f"
st = asc_hex(oldpass, password(0), 3) '十六进制转换
If st < 0 Then
MsgBox "插卡错误,请插入指定卡型,点击重试", , "提示信息:"
Exit Sub
End Ifst = csc_4442(icdev, 3, password(0))
If st < 0 Then '卡片指定的密码错误
MsgBox "卡指定密码错误,请插入指定的卡重试", , "提示信息:"
Exit Sub
End If '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$没调试,计数为 0¥¥¥¥¥¥¥¥¥¥¥¥¥¥
st = rsct_4442(icdev, counter)
If st < 0 Then
MsgBox "此卡无效,请换卡重试", , "提示信息:"
Exit Sub
End IfIf counter < 0 Then
MsgBox "此卡无效,请换卡重试", , "提示信息:"
Exit Sub
End If'################################ ¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥a = 40
a1 = 6
st = srd_4442(icdev, a, a1, Data1)
If st < 0 Then
MsgBox "卡读取错误,请仔细确认后点击重试1", , "提示信息:"
Exit Sub
End Ifkahao.Caption = Data1