I assumed that you have taken RichTextBox.
there is one Property Modified, you can make use of it, and you can also set its value.
whenever you right in RichTextBox. Modified property returns true. so whenever user formclose then use
this condition to check whether its modified or not.
for save button: add one more statement:
RichTextBox1.Modified = False
and in form_closing
Private Sub Form1_FormClosing(ByVal
sender As Object,
ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles
Me.FormClosing
If
(RichTextBox1.Modified) Then
If
MessageBox.Show("Are you sure you want to exit
without saving changes?", "Exiting",
_
MessageBoxButtons.YesNo,
MessageBoxIcon.Question) = DialogResult.No Then
e.Cancel = True
End
If
End If
End Sub