Hello,

I've been working on a private project for the last hour and want to do this..
I want the program to automatically save the form contents when the user presses close or if the form closes accidentally.

In my code, I told the program to check the first field to see if it is filled or not. If it is filled, then I told the program to activate the procedure that saves the form contents to the file. If it is empty, I want the form to automatically close down. In my normal save procedure, the first line checks to see if the first field is empty or not. If it is not, it tells the user to complete the field.

Anyway, here's the code I used:

Private Sub Form2_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

If wrd_txtbx.Text = "" Then
Me.Close()
Else

addnew_btn.PerformClick()

End If

End Sub

The first part of my addnew (which lets m save the contents of the form to a file), looks like this...

If

wrd_txtbx.Text = "" Or pos_cb1.Text = "" Then

MsgBox(

"Word field and Part of Speech cannot be empty")

Else

some other procedure steps
....

When I go to press close the form, I get an error stating the following:

System.StackOverflowException was unhandled
InnerException:
'make sure you do not have an infinite loop or infinite recursion

My questions are
1. What is an infinite loop or recursion loop?

2. Do i keep getting this error because of this line in my addnew procedure

If wrd_txtbx.Text = "" Or pos_cb1.Text = ""

and this line in my FormClosing Procedure

If wrd_txtbx.Text = "" Then

3.)How do i fix the error?

Gracias(Akua O Asamoah,salerack)