VB Simple Ascii to Hex Convertor + Source

VB.Net 字串轉換成機械馬(Array of Bytes)
轉自:http://www.gamersoul.com/forums/showthread.php?123800-Simple-Ascii-to-Hex-Convertor-Source


I'm trying out some stuff on vb.NET cause it's fun to do :D

Download exe





Source:
2 Textboxes (name one inputASCII, and the other outputHEX)
2 Buttons (name one btnClear, and the other btnCopy

Code:
Public Class Form1

    Private Sub inputASCII_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles inputASCII.TextChanged
        Dim str As String
        Dim byteArray() As Byte
        Dim asciihexOUT As System.Text.StringBuilder = New System.Text.StringBuilder


        str = inputASCII.Text


        byteArray = System.Text.ASCIIEncoding.ASCII.GetBytes(str)


        For i As Integer = 0 To byteArray.Length - 1
            asciihexOUT.Append(byteArray(i).ToString("X") + (" "))
        Next


        outputHEX.Text = (asciihexOUT.ToString())
    End Sub


    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        inputASCII.Text = Nothing
    End Sub


    Private Sub btnCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCopy.Click
        Clipboard.SetText(outputHEX.Text)
    End Sub
End Class


留言

張貼留言

本月最夯

偷用電腦,怎知?事件檢視器全記錄!(開機時間、啟動項時間...)