将字符串拆分为对

K_M*_*mic 5 vb.net split

我怎样才能在VB中将字符串拆分成双字母?

例如:abcdefgh

分成:ab cd ef gh

Lar*_*ech 8

我会把帽子扔进戒指:

Dim test As String = "abcdefgh"
Dim results As New List(Of String)

For i As Integer = 0 To test.Length - 1 Step 2
  If i + 1 < test.Length Then
    results.Add(test.Substring(i, 2))
  Else
    results.Add(test.Substring(i))
  End If
Next

MessageBox.Show(String.Join(" ", results.ToArray))
Run Code Online (Sandbox Code Playgroud)