Option Explicit On
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim hexLine As String
Dim strData As String = ""
hexLine = FixStr(textBox1.Text)
Dim StrLen As Integer = hexLine.Length
Dim a As Integer = 0
While a < StrLen
strData = strData & Byte.Parse(hexLine.Substring(a, 2), System.Globalization.NumberStyles.HexNumber)
'output.WriteByte(Byte.Parse(hexLine.Substring(a, 2), System.Globalization.NumberStyles.HexNumber))
a = a + 2
End While
Call WriteData(strData)
End Sub
Public Sub WriteData(ByVal strData As String)
FileOpen(5, System.AppDomain.CurrentDomain.BaseDirectory & "hex_final.txt", OpenMode.Output)
PrintLine(5, strData)
FileClose(5)
End Sub
Public Function FixStr(ByRef TheString As String) As String
FixStr = TheString
FixStr = Replace(FixStr, vbCrLf, "")
FixStr = Replace(FixStr, vbTab, "")
FixStr = Replace(FixStr, vbCr, "")
FixStr = Replace(FixStr, vbLf, "")
FixStr = Replace(FixStr, " ", "")
End Function
End Class
|