Codes

File Open

If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then
s = Me.OpenFileDialog1.FileName()
Me.RichTextBox1.LoadFile(s, RichTextBoxStreamType.PlainText)
b = 1
End If

Save File

If b = 1 Then
Me.RichTextBox1.SaveFile(s, RichTextBoxStreamType.PlainText)
End If
If b = 0 Then

If Me.SaveFileDialog1.ShowDialog = DialogResult.OK Then
s = Me.SaveFileDialog1.FileName
Me.RichTextBox1.SaveFile(s, RichTextBoxStreamType.PlainText)
End If
b = 1
End If

New file

If a = 0 Then
RichTextBox1.Text = “”
ElseIf a = 1 Then
Dim i As Integer
i = MessageBox.Show(“Do you want to save your changes”, “Save file”, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, MessageBoxOptions.ServiceNotification)
If i = DialogResult.Yes Then
If b = 1 Then
s = Me.SaveFileDialog1.FileName
Me.RichTextBox1.SaveFile(s, RichTextBoxStreamType.PlainText)

End If
If b = 0 Then

If Me.SaveFileDialog1.ShowDialog = DialogResult.OK Then
s = Me.SaveFileDialog1.FileName
Me.RichTextBox1.SaveFile(s, RichTextBoxStreamType.PlainText)
End If
b = 1
End If
RichTextBox1.Text = “”
a = 0
b = 0

ElseIf i = DialogResult.No Then
RichTextBox1.Text = “”
a = 0
b = 0
End If

End If

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s