Some Text Assistance Please

TyE14

New member
Joined
Aug 8, 2007
Messages
4
Programming Experience
Beginner
Can someone please help me. What I am trying to do is I got a form (Form1) a button (Button1) and 2 Textboxes (TextBox1 & TextBox2). I want to make it so that when someone types text in TextBox1 its in hexadecmial. I don't want it to convert it to hexidecmail though. When I click the button, I want it so that TextBox2 adds 4 Hex to the line in TextBox1 for 4 lines and putting the original line on the top with TextBox2 then having a total of 5 lines. For example this is what I want:

TextBox1:

568BCE4C

TextBox2:

568BCE4C
568BCE50
568BCE54
568BCE58
568BCE5C

Thanks if someone can help me because I am not good at programming and can't figure it out.
 
VB.NET:
Dim hex As String = textInput.Text
Dim sb As New System.Text.StringBuilder
sb.AppendLine(hex)
Dim int As Integer = Convert.ToInt32(hex, 16)
For i As Integer = 1 To 4
    int += 4
    sb.AppendFormat("{0:X}", int)
    sb.AppendLine()
Next
txtOutput.Text = sb.ToString
 
TryParse is more secure than Convert.ToInt32, so you could use this instead:
VB.NET:
Dim int As Integer 
If Integer.TryParse(hex, Globalization.NumberStyles.HexNumber, Nothing, int) Then
...
End If
 
Thanks alot man your awesome :). I just have one small problem...it says: " 'AppendLine' is not a member of 'System.Text.StringBuilder'. "
 
That overload is new in .Net 2.0, it was just for adding a linefeed which you can also do with vbNewLine. Is your forum profile wrong?
 
Yes it is wrong sorry. I don't know how to add in vbNewLine sorry I am really new to programming and not very good but thanks for helping me.
 
.Append(variable & vbNewLine)

or

.Append(variable & vbCrLf)

or

.Append(variable & Environment.NewLine)


The last example would be the proper .NET way if you aren't on .NET 2.0 framework. The first two do the same thing, but it's always a good idea to get out of the habit of using old-school VB globals.
 
Back
Top