怎么用VB.NET做一个记事本

是VB.NET... 是VB.NET 展开
 我来答
bufanlin
2008-10-02
知道答主
回答量:5
采纳率:100%
帮助的人:5万
展开全部
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

OpenFileDialog1.ShowDialog()

RichTextBox1.LoadFile(Me.OpenFileDialog1.FileName, RichTextBoxStreamType.PlainText)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim fname As String
Me.SaveFileDialog1.ShowDialog()
fname = Me.SaveFileDialog1.FileName

If (fname <> "") Then

If (Me.OpenFileDialog1.FilterIndex = 1) Then
Me.RichTextBox1.SaveFile(fname, RichTextBoxStreamType.PlainText)
Else
Me.RichTextBox1.SaveFile(fname, RichTextBoxStreamType.RichText)

End If

End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.SaveFileDialog2.ShowDialog()

If (Me.OpenFileDialog1.FileName <> "") Then

If (Me.OpenFileDialog1.FilterIndex = 1) Then

Me.RichTextBox1.SaveFile(Me.SaveFileDialog2.FileName, RichTextBoxStreamType.PlainText)
Else
Me.RichTextBox1.SaveFile(Me.SaveFileDialog2.FileName, RichTextBoxStreamType.RichText)

End If

End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.FontDialog1.Font = Me.RichTextBox1.SelectionFont
If (Me.FontDialog1.ShowDialog() = Me.DialogResult.OK) Then
Me.RichTextBox1.SelectionFont = Me.FontDialog1.Font

End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Me.ColorDialog1.Color = Me.RichTextBox1.SelectionColor
If (Me.ColorDialog1.ShowDialog() = Me.DialogResult.OK) Then

Me.RichTextBox1.SelectionColor = Me.ColorDialog1.Color
End If

End Sub

Private Sub 打开ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 打开ToolStripMenuItem.Click
Try
Dim str As String
Dim typel As System.Windows.Forms.RichTextBoxStreamType
OpenFileDialog1.ShowDialog()
str = OpenFileDialog1.FileName
RichTextBox1.LoadFile(str, RichTextBoxStreamType.PlainText)
Catch ex As Exception
End Try
End Sub

Private Sub 保存ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 保存ToolStripMenuItem.Click
Me.SaveFileDialog1.ShowDialog()

If (Me.SaveFileDialog1.FileName <> "") Then

If (Me.OpenFileDialog1.FilterIndex = 1) Then
Me.RichTextBox1.SaveFile(Me.SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText)
Else

Me.RichTextBox1.SaveFile(Me.SaveFileDialog1.FileName, RichTextBoxStreamType.RichText)

End If

End If

End Sub

Private Sub 另存为ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 另存为ToolStripMenuItem.Click
Me.SaveFileDialog1.ShowDialog()

If (Me.OpenFileDialog1.FileName <> "") Then

If (Me.OpenFileDialog1.FilterIndex = 1) Then
Me.RichTextBox1.SaveFile(Me.SaveFileDialog1.FileName, RichTextBoxStreamType.PlainText)
Else
Me.RichTextBox1.SaveFile(Me.SaveFileDialog1.FileName, RichTextBoxStreamType.RichText)

End If

End If
End Sub

Private Sub 退出ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 退出ToolStripMenuItem.Click
End

End Sub

Private Sub 字体ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 字体ToolStripMenuItem.Click
Me.FontDialog1.Font = Me.RichTextBox1.SelectionFont
If (Me.FontDialog1.ShowDialog() = Me.DialogResult.OK) Then
Me.RichTextBox1.SelectionFont = Me.FontDialog1.Font

End If
End Sub

Private Sub 颜色ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 颜色ToolStripMenuItem.Click
Me.ColorDialog1.Color = Me.RichTextBox1.SelectionColor
If (Me.ColorDialog1.ShowDialog() = Me.DialogResult.OK) Then

Me.RichTextBox1.SelectionColor = Me.ColorDialog1.Color
End If

End Sub

Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles SaveFileDialog1.FileOk

End Sub
End Class
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式