📄 frmconverter.frm
字号:
VERSION 5.00
Begin VB.Form frmConverter
BorderStyle = 3 'Fixed Dialog
Caption = "Data Converter"
ClientHeight = 4620
ClientLeft = 2940
ClientTop = 3225
ClientWidth = 7800
Icon = "frmConverter.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4620
ScaleWidth = 7800
ShowInTaskbar = 0 'False
Begin VB.CheckBox chkFillBlock
Caption = "Fill Block"
Height = 255
Index = 2
Left = 6600
TabIndex = 20
Top = 3240
Width = 1095
End
Begin VB.CheckBox chkFillBlock
Caption = "Fill Block"
Height = 255
Index = 1
Left = 6600
TabIndex = 19
Top = 1920
Width = 1095
End
Begin VB.CheckBox chkFillBlock
Caption = "Fill Block"
Height = 255
Index = 0
Left = 6600
TabIndex = 18
Top = 600
Width = 1095
End
Begin VB.CommandButton cmdCommand
Caption = "Clear"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 2
Left = 4680
TabIndex = 17
Top = 4020
Width = 1815
End
Begin VB.CommandButton cmdCommand
Caption = "Auto-fill HEX value"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 1
Left = 2280
TabIndex = 16
Top = 4020
Width = 2055
End
Begin VB.CommandButton cmdCommand
Caption = "Convert"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Index = 0
Left = 120
TabIndex = 15
Top = 4020
Width = 1815
End
Begin VB.Frame Frame1
Caption = " Block 2 "
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 1215
Index = 2
Left = 120
TabIndex = 10
Top = 2700
Width = 6375
Begin VB.TextBox txtDataHex
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 2
Left = 1080
MaxLength = 32
TabIndex = 14
Top = 300
Width = 5115
End
Begin VB.TextBox txtDataASCII
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 2
Left = 1080
MaxLength = 16
TabIndex = 13
Top = 720
Width = 5115
End
Begin VB.OptionButton optFormatHEX
Caption = "HEX"
Height = 315
Index = 2
Left = 180
TabIndex = 12
Top = 300
Width = 855
End
Begin VB.OptionButton optFormatASCII
Caption = "ASCII"
Height = 315
Index = 2
Left = 180
TabIndex = 11
Top = 720
Width = 855
End
End
Begin VB.Frame Frame1
Caption = " Block 1 "
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 1215
Index = 1
Left = 120
TabIndex = 5
Top = 1380
Width = 6375
Begin VB.TextBox txtDataHex
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 1
Left = 1080
MaxLength = 32
TabIndex = 9
Top = 300
Width = 5115
End
Begin VB.TextBox txtDataASCII
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 1
Left = 1080
MaxLength = 16
TabIndex = 8
Top = 720
Width = 5115
End
Begin VB.OptionButton optFormatHEX
Caption = "HEX"
Height = 315
Index = 1
Left = 180
TabIndex = 7
Top = 300
Width = 855
End
Begin VB.OptionButton optFormatASCII
Caption = "ASCII"
Height = 315
Index = 1
Left = 180
TabIndex = 6
Top = 720
Width = 855
End
End
Begin VB.Frame Frame1
Caption = " Block 0 "
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00C00000&
Height = 1215
Index = 0
Left = 120
TabIndex = 0
Top = 60
Width = 6375
Begin VB.OptionButton optFormatASCII
Caption = "ASCII"
Height = 315
Index = 0
Left = 180
TabIndex = 4
Top = 720
Width = 855
End
Begin VB.OptionButton optFormatHEX
Caption = "HEX"
Height = 315
Index = 0
Left = 180
TabIndex = 3
Top = 300
Width = 855
End
Begin VB.TextBox txtDataASCII
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 0
Left = 1080
MaxLength = 16
TabIndex = 2
Top = 720
Width = 5115
End
Begin VB.TextBox txtDataHex
BeginProperty Font
Name = "Courier"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Index = 0
Left = 1080
MaxLength = 32
TabIndex = 1
Top = 300
Width = 5115
End
End
End
Attribute VB_Name = "frmConverter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub DoConversion()
Dim i As Integer
Dim j As Integer
Dim k As Integer
Dim intLen As Integer
Dim intStep As Integer
Dim intChar As Long
Dim strChar As String
Dim strTemp As String
Dim strResult As String
For i = 0 To 2
If optFormatHEX(i).Value = True Then
txtDataHex(i) = Left$(Trim$(txtDataHex(i)) & String$(32, "F"), 32)
intLen = 32
intStep = 2
strTemp = txtDataHex(i)
ElseIf optFormatASCII(i).Value = True Then
txtDataASCII(i) = Left$(Trim$(txtDataASCII(i)) & String$(16, " "), 16)
intLen = 16
intStep = 1
strTemp = txtDataASCII(i)
Else
intLen = 0
strTemp = ""
End If
strResult = ""
'Convertion process based on which format option is choose for each block (ASCII or HEX)
For j = 1 To intLen Step intStep
strChar = Mid$(strTemp, j, intStep)
If optFormatHEX(i).Value = True Then 'Option HEX is choosen, then convert HEX to ASCII
intChar = Hex2Dec(strChar)
strResult = strResult & Chr$(intChar)
ElseIf optFormatASCII(i).Value = True Then 'Option ASCII is choosen, then convert ASCII to HEX
strResult = strResult & Format(Hex(Asc(strChar)), "00")
End If
Next
'Store the convertion result
If optFormatHEX(i).Value = True Then
txtDataASCII(i).Text = strResult
ElseIf optFormatASCII(i).Value = True Then
txtDataHex(i).Text = strResult
End If
Next
End Sub
Private Sub cmdCommand_Click(Index As Integer)
Dim i As Integer
Select Case Index
Case 0 'Convert
Call DoConversion
Case 1 'Auto Fill
If chkFillBlock(0).Value = 1 Then frmMifareUSB.txtDataBlock(0).Text = txtDataHex(0).Text
If chkFillBlock(1).Value = 1 Then frmMifareUSB.txtDataBlock(1).Text = txtDataHex(1).Text
If chkFillBlock(2).Value = 1 Then frmMifareUSB.txtDataBlock(2).Text = txtDataHex(2).Text
Unload Me
Case 2 'Clear
txtDataASCII(0).Text = ""
txtDataASCII(1).Text = ""
txtDataASCII(2).Text = ""
txtDataHex(0).Text = ""
txtDataHex(1).Text = ""
txtDataHex(2).Text = ""
End Select
End Sub
Private Sub Form_Activate()
optFormatHEX(2).Value = True
optFormatHEX(1).Value = True
optFormatHEX(0).Value = True
Call DoConversion
End Sub
Private Sub Form_Load()
CenterMe Me
End Sub
Private Sub optFormatASCII_Click(Index As Integer)
optFormatASCII(Index).FontBold = True
optFormatASCII(Index).FontUnderline = True
optFormatHEX(Index).FontBold = False
optFormatHEX(Index).FontUnderline = False
txtDataASCII(Index).SetFocus
End Sub
Private Sub optFormatHEX_Click(Index As Integer)
optFormatHEX(Index).FontBold = True
optFormatHEX(Index).FontUnderline = True
optFormatASCII(Index).FontBold = False
optFormatASCII(Index).FontUnderline = False
txtDataHex(Index).SetFocus
End Sub
Private Sub txtDataHex_KeyPress(Index As Integer, KeyAscii As Integer)
Dim bolAccepted As Boolean
bolAccepted = False
If KeyAscii >= 48 And KeyAscii <= 57 Then '0 ~ 9
bolAccepted = True
ElseIf KeyAscii >= 65 And KeyAscii <= 70 Then 'a ~ f
bolAccepted = True
ElseIf KeyAscii >= 97 And KeyAscii <= 102 Then 'A ~ F
bolAccepted = True
ElseIf KeyAscii = 8 Then
bolAccepted = True
End If
If Not bolAccepted Then
KeyAscii = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -