Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to check before colsing a program if any information has to be sav

Status
Not open for further replies.

SamNeo

Technical User
Jun 26, 2000
21
IN
I am creating a notepad like program of my own in vb I want to know how to verify the condition that if a file that is present in the note pad is to be save or not and display a message to the user like the usual windows notepad.
If any can help please mail me
I have tried the following code of my own but does not work

this is the exit function. for my program
Private Sub xit_Click(Index As Integer)
If Text1.Text = "" Then
Unload Me
Else
MsgBox "The file is not saved do you want to save it", vbYesNo
If True Then
Call open_Click(0)
Else
Unload Me
End If
End If
End Sub
how can it be modified to work properly
 
Create a form level boolean called HasChanged. By default,
HasChanged will be set to False when the program starts.

In the Change event of your Text box, put: HasChanged = True

This will only be set to True if the Change Event fires. The Change event will only fire if something has changed.

In your Exit Function, put:

If HasChanged = True Then
Do Whatever
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top