Hello,
I'm trying to create an algorithm that allows me to calculate the next alphanumeric string but so far, no luck...
I'm getting overflows when strings are too big, plus I couldn't find a way to correct find the next alphanumeric value
thanks
I'm trying to create an algorithm that allows me to calculate the next alphanumeric string but so far, no luck...
I'm getting overflows when strings are too big, plus I couldn't find a way to correct find the next alphanumeric value
Code:
Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged
Dim __Code As String
__Code = TextBox1.Text
Try
TextBox2.Text = HexToString((Convert.ToInt64(StrToHex(__Code), 16) + 1).ToString("X"))
Catch ex As Exception
'
End Try
End Sub
Public Function StrToHex(ByVal Data As String) As String
Dim sVal As String
Dim sHex As String = ""
While Data.Length > 0
sVal = Conversion.Hex(Strings.Asc(Data.Substring(0, 1).ToString()))
Data = Data.Substring(1, Data.Length - 1)
sHex = sHex & sVal
End While
Return sHex
End Function
Function HexToString(ByVal hex As String) As String
Dim text As New System.Text.StringBuilder(hex.Length \ 2)
For i As Double = 0 To hex.Length - 2 Step 2
text.Append(Chr(Convert.ToByte(hex.Substring(i, 2), 16)))
Next
Return text.ToString
End Function