你是想要这种效果吗?
Dim str As String = TextBox1.Text
Dim b() As Byte = System.Text.Encoding.Unicode.GetBytes(str)
Dim i As Integer
Dim bb(100) As Byte
Dim t As Integer = 0
Dim j As Integer
For j = 0 To b.Length - 1
If b(j) <> 0 Then
bb(t) = b(j)
t = t + 1
End If
Next
MsgBox(t.ToString())