0

I am trying to split the letters in a textbox in to letters and add it to a listbox. And then convert each letter separately to unicode and add "| " at the end of each letter. For example;
Lets say we have a
• listbox called "lst1" put separated letters into this
• Textbox called "tx1" put the input string here
• A Second Textox called "tx2" final output locatin

This is the code i am currently trying to use

Dim s As String = tx1.Text
        Dim arrayLetters As Array = Split(s)
        Dim i As Integer
        For i = 0 To UBound(arrayLetters)
           lst1.Items.Add(arrayLetters(i))
        Next

I am not able to figure out the rest of the code. Please help me

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by GeekByChoiCe
0

hope i understood your question correctly

Private Sub ShortWay()
		Dim st As String = "myString"
		Dim result As String = String2Unicode(st).Replace(Chr(0), Chr(0) & "|")
		Console.WriteLine(result)
	End Sub

	Private Sub LongWay()
		Dim st As String = "myString"
		Dim sb As New Text.StringBuilder
		For Each c As Char In st
			sb.AppendFormat("{0}|", String2Unicode(c))
		Next
		Console.WriteLine(sb.ToString)
	End Sub

	Private Function String2Unicode(ByVal s As String) As String
		Dim sSearchUnicode As Byte() = System.Text.Encoding.Unicode.GetBytes(s)
		Return System.Text.Encoding.Default.GetString(sSearchUnicode)
	End Function
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.