'字符串操作-对于不存在于文本的输入字符串进行追加保存操作
Dim path As String = Application.StartupPath & "\wz.txt"
Dim readText As String = File.ReadAllText(path) '打开文件,读取文件的所有行,然后关闭文件
Dim hanzihang() As String '汉字数组变量
hanzihang = Split(readText, vbCrLf) '这两句从文件中获得每行汉字的内容存入数组
Dim i As Integer = 0
Dim s As String = ""
While i < hanzihang.Length - 1
If TextBox3.Text = hanzihang(i) Then
s = hanzihang(i) '这个字符串变量用来和输入框做对比
TextBox1.Text = TextBox1.Text & Format(Now, "hh:mm:ss") & "操作者: " & TextBox3.Text & vbCrLf & _
"提示:字符串识别成功,编号" & i + 1 & "#" & vbCrLf & Format(Now, "hh:mm:ss") & "系统: " & "暂无互动信息" & vbCrLf
End If
i = i + 1
End While
If s = TextBox3.Text Then
Else
Dim appendText As String = TextBox3.Text + Environment.NewLine '打开文件,向文件追加字符串,然后关闭文件
File.AppendAllText(path, appendText)
TextBox1.Text = TextBox1.Text & Format(Now, "hh:mm:ss") & "操作者: " & TextBox3.Text & vbCrLf & _
"提示:不存在该字符串,该字符串以写入文件!" & vbCrLf & Format(Now, "hh:mm:ss") & "系统: " & "该字符串保存成功" & vbCrLf
End If