(8)记录区核心代码
1) “背景颜色”按钮单击事件代码
Private Sub BtBackColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtBackColor.Click
With Me.ColorDialog1
.ShowDialog()
TxtListen.BackColor = .Color
End With
End Sub
2) “字体”按钮单击事件代码
Private Sub BtFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtFont.Click
With Me.FontDialog1
.ShowDialog()
TxtListen.Font = .Font
End With
End Sub
3) “打开”按钮单击事件代码
Private Sub BtOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtOpen.Click
Dim FilePath As String
With Me.OpenFileDialog1
.Title = "打开听写记录"
.CheckFileExists = True
.CheckPathExists = True
.Multiselect = False
.Filter = "文本文件(.txt)|*.txt"
If .ShowDialog() = Windows.Forms.DialogResult.Cancel Then
Exit Sub
End If
FilePath = .FileName
End With
' Dim MyStreamRead As IO.StreamReader
' MyStreamRead = IO.File.OpenText(FilePath)
'Dim MyReceiver As String
'MyReceiver = MyStreamRead.ReadLine()
'While Not MyReceiver Is Nothing
'Me.TxtListen.AppendText(MyReceiver & ControlChars.CrLf)
'MyReceiver = MyStreamRead.ReadLine()
'End While
'MyStreamRead.Close()
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText(FilePath,System.Text.Encoding.Default)
TxtListen.Text = fileReader
End Sub
|