Private Sub Ch1_Click() '------------------------------------------------------------ '说明: 判断是否是输入十六时制数,而设定文本框数据接授长度 '------------------------------------------------------------ TDown = "" If Ch1.Value = 1 Then TDown.MaxLength = 256 * 3 Else TDown.MaxLength = 256 End If End Sub
Private Sub ComExit_Click() Unload Me '退出 End Sub Private Sub ComRead_Click() '------------------------------------------------------------ '说明: 先判断输入的数据是否符合要求,然后传给读函数 '------------------------------------------------------------ Dim BgnAdr_L As Integer Dim BgnAdr_H As Integer Dim nLen As Integer Dim Str As String Dim str2 As String '用于接收返回值
On Error GoTo HaveErr
If Len(Trim(TIAdd)) = 0 Then MsgBox "请输入读数据的起始地址!", vbInformation, "提示" Exit Sub End If
If Len(Trim(Tlen)) = 0 Then MsgBox "请输入数据长度!", vbInformation, "提示" Exit Sub End If
If Val(Trim(Tlen)) > 256 Then MsgBox "最多只能读取256个数据!", vbInformation, "提示" Exit Sub End If BgnAdr_L = HtoD(Trim(TDAdd)) BgnAdr_H = 0 nLen = Val(Trim(Tlen))
If Len(str2) <> 0 Then TIncept = "" If Ch2.Value = 1 Then TIncept = StoH(str2) Else TIncept = str2 End If MsgBox "读E2PROM数据成功!", vbInformation, "提示" Else MsgBox "读E2PROM数据出错!", vbInformation, "提示" End If
Exit Sub HaveErr: MsgBox "对不起!系统出错,请重新操作。", vbInformation, "提示" End Sub
Private Sub ComWrite_Click() '------------------------------------------------------------ '说明: 先判断输入的数据是否符合要求,然后传给写函数 '------------------------------------------------------------ Dim BgnAdr_L As Integer Dim BgnAdr_H As Integer Dim Str As String Dim str2 As String
On Error GoTo HaveErr
If Len(Trim(TDAdd)) = 0 Then MsgBox "请输入写数据的起始地址!", vbInformation, "提示" Exit Sub End If
If Len(Trim(TDown)) = 0 Then MsgBox "请输入要写入的数据!", vbInformation, "提示" Exit Sub End If
BgnAdr_L = HtoD(Trim(TDAdd)) BgnAdr_H = 0
If Ch1.Value = 1 Then Str = HtoS(TDown) Else Str = Trim(TDown) End If If (BgnAdr_L + Len(Str)) > TDown.MaxLength Then MsgBox "下载数据过长,请修改!", vbInformation, "提示" Exit Sub End If
st = WriteE2PRom(BgnAdr_L, BgnAdr_H, Str) If st <> 0 Then MsgBox "写数据有误,请重新操作!", vbInformation, "提示" Exit Sub End If MsgBox "写E2PROM数据成功!", vbInformation, "提示"
Exit Sub HaveErr: MsgBox "对不起!系统出错,请重新操作。", vbInformation, "提示"
End Sub Private Sub TDAdd_KeyPress(KeyAscii As Integer) '------------------------------------------------------------ ' 判断输入是否为有效字符符(十六进制数) '------------------------------------------------------------
Select Case KeyAscii Case 8 Case 48 To 57 Case 65 To 70 Case 97 To 102 Case Else KeyAscii = 0 End Select
End Sub Private Sub TDown_KeyPress(KeyAscii As Integer) '------------------------------------------------------------ ' 判断输入是否为有效字符符(十六进制数),及空格 '------------------------------------------------------------ If Ch1.Value = 1 Then Select Case KeyAscii Case 8 Case 32 '空格 Case 48 To 57 Case 65 To 70 Case 97 To 102 Case Else KeyAscii = 0 End Select End If End Sub
Private Sub TIAdd_KeyPress(KeyAscii As Integer) '------------------------------------------------------------ ' 判断输入是否为有效字符符(十六进制数) '------------------------------------------------------------ Select Case KeyAscii Case 8 Case 48 To 57 Case 65 To 70 Case 97 To 102 Case Else KeyAscii = 0 End Select End Sub
Private Sub TIncept_KeyPress(KeyAscii As Integer) KeyAscii = 0 End Sub
Private Sub Tlen_KeyPress(KeyAscii As Integer) '------------------------------------------------------------ ' 判断输入是否为有效字符符(十进制数) '------------------------------------------------------------ Select Case KeyAscii Case 8 Case 48 To 57 Case Else KeyAscii = 0 End Select End Sub
Private Sub Ch1_Click()
'------------------------------------------------------------
'说明: 判断是否是输入十六时制数,而设定文本框数据接授长度
'------------------------------------------------------------
TDown = ""
If Ch1.Value = 1 Then
TDown.MaxLength = 256 * 3
Else
TDown.MaxLength = 256
End If
End Sub
Private Sub ComExit_Click()
Unload Me '退出
End Sub
Private Sub ComRead_Click()
'------------------------------------------------------------
'说明: 先判断输入的数据是否符合要求,然后传给读函数
'------------------------------------------------------------
Dim BgnAdr_L As Integer
Dim BgnAdr_H As Integer
Dim nLen As Integer
Dim Str As String
Dim str2 As String '用于接收返回值
On Error GoTo HaveErr
If Len(Trim(TIAdd)) = 0 Then
MsgBox "请输入读数据的起始地址!", vbInformation, "提示"
Exit Sub
End If
If Len(Trim(Tlen)) = 0 Then
MsgBox "请输入数据长度!", vbInformation, "提示"
Exit Sub
End If
If Val(Trim(Tlen)) > 256 Then
MsgBox "最多只能读取256个数据!", vbInformation, "提示"
Exit Sub
End If
BgnAdr_L = HtoD(Trim(TDAdd))
BgnAdr_H = 0
nLen = Val(Trim(Tlen))
str2 = ""
str2 = ReadE2PRom(BgnAdr_L, BgnAdr_H, nLen)
If Len(str2) <> 0 Then
TIncept = ""
If Ch2.Value = 1 Then
TIncept = StoH(str2)
Else
TIncept = str2
End If
MsgBox "读E2PROM数据成功!", vbInformation, "提示"
Else
MsgBox "读E2PROM数据出错!", vbInformation, "提示"
End If
Exit Sub
HaveErr:
MsgBox "对不起!系统出错,请重新操作。", vbInformation, "提示"
End Sub
Private Sub ComWrite_Click()
'------------------------------------------------------------
'说明: 先判断输入的数据是否符合要求,然后传给写函数
'------------------------------------------------------------
Dim BgnAdr_L As Integer
Dim BgnAdr_H As Integer
Dim Str As String
Dim str2 As String
On Error GoTo HaveErr
If Len(Trim(TDAdd)) = 0 Then
MsgBox "请输入写数据的起始地址!", vbInformation, "提示"
Exit Sub
End If
If Len(Trim(TDown)) = 0 Then
MsgBox "请输入要写入的数据!", vbInformation, "提示"
Exit Sub
End If
BgnAdr_L = HtoD(Trim(TDAdd))
BgnAdr_H = 0
If Ch1.Value = 1 Then
Str = HtoS(TDown)
Else
Str = Trim(TDown)
End If
If (BgnAdr_L + Len(Str)) > TDown.MaxLength Then
MsgBox "下载数据过长,请修改!", vbInformation, "提示"
Exit Sub
End If
st = WriteE2PRom(BgnAdr_L, BgnAdr_H, Str)
If st <> 0 Then
MsgBox "写数据有误,请重新操作!", vbInformation, "提示"
Exit Sub
End If
MsgBox "写E2PROM数据成功!", vbInformation, "提示"
Exit Sub
HaveErr:
MsgBox "对不起!系统出错,请重新操作。", vbInformation, "提示"
End Sub
Private Sub TDAdd_KeyPress(KeyAscii As Integer)
'------------------------------------------------------------
' 判断输入是否为有效字符符(十六进制数)
'------------------------------------------------------------
Select Case KeyAscii
Case 8
Case 48 To 57
Case 65 To 70
Case 97 To 102
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TDown_KeyPress(KeyAscii As Integer)
'------------------------------------------------------------
' 判断输入是否为有效字符符(十六进制数),及空格
'------------------------------------------------------------
If Ch1.Value = 1 Then
Select Case KeyAscii
Case 8
Case 32 '空格
Case 48 To 57
Case 65 To 70
Case 97 To 102
Case Else
KeyAscii = 0
End Select
End If
End Sub
Private Sub TIAdd_KeyPress(KeyAscii As Integer)
'------------------------------------------------------------
' 判断输入是否为有效字符符(十六进制数)
'------------------------------------------------------------
Select Case KeyAscii
Case 8
Case 48 To 57
Case 65 To 70
Case 97 To 102
Case Else
KeyAscii = 0
End Select
End Sub
Private Sub TIncept_KeyPress(KeyAscii As Integer)
KeyAscii = 0
End Sub
Private Sub Tlen_KeyPress(KeyAscii As Integer)
'------------------------------------------------------------
' 判断输入是否为有效字符符(十进制数)
'------------------------------------------------------------
Select Case KeyAscii
Case 8
Case 48 To 57
Case Else
KeyAscii = 0
End Select
End Sub
我用的是利尔达d12 芯片 开发版
设计的 射频卡usb读写器了解更多 请登录到我的网站 http://leek.woku.com http://www.duanliqing.kudo.cn