我正在使用Visual Basic 2010 Express。我需要解析一个带有不可打印字符的字符串。我需要检测ASCII 4(传输结束)。
扫描仪将数据转储到我的应用程序中的TextBox中。循环中,我正在使用:
If Chr(MyString.Chars(counter)) = 4 Then
MsgBox("Found")
End If
这不是正确的语法,但应该传达我正在尝试做的事情。
答案 0 :(得分:1)
扫描仪将数据转储到文本框后:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TextBox1.Text = "Some chars coming in from " & Chr(4) & " a scanner"
End Sub
尝试这样的事情:
Dim MyString As String = TextBox1.Text
If MyString.Contains(Chr(4)) Then
MessageBox.Show("Found")
End If
甚至是这样的东西:
Dim MyString As String = TextBox1.Text
Dim counter As Integer = 26
If MyString.Chars(counter) = Chr(4) Then
MessageBox.Show("Found")
End If