keeyean
Civil/Environmental
- Sep 11, 2001
- 14
i have a question regarding visual basic close program porblem....
i have this code in the mnu...
a msg will be asked if any changed in file... but how do i link this to the left hand window corner "X- button"...so that, a msg will be asked too when i close the program from the "x-button"??
Public Sub mnuExit_Click()
If FileHasChanged = True Then
Style = vbYesNoCancel + vbQuestion
Response = MsgBox("Do you want to save this file?", Style)
If Response = vbYes Then
Call mnuSaveAs_Click
ElseIf Response = vbNo Then
End
UnloadAllForm
ElseIf Response = vbCancel Then
Exit Sub
End If
Else
End
UnloadAllForm
End If
End Sub
this is what will happen when i close the program from the "x-button"
1.)when i click the "x-button".. the Form that display on the MDIForm will invisible... and a msg "do you want to save the file?" will pop up...
2.)when i select "Yes"....a save dialog will pop up.. but once i select "Cancel" from the save dialog... the MDIForm will invisible...
3.)when i select cancel(from the msg).. the MDIForm will invisible also..
if i close the program from the file menu...it work fine..
hope you can follow..
besides, i have another question at here....
why all the comboboxes i have in the program will be highlighted? and how do i prevent this to happen??
i have this code in the mnu...
a msg will be asked if any changed in file... but how do i link this to the left hand window corner "X- button"...so that, a msg will be asked too when i close the program from the "x-button"??
Public Sub mnuExit_Click()
If FileHasChanged = True Then
Style = vbYesNoCancel + vbQuestion
Response = MsgBox("Do you want to save this file?", Style)
If Response = vbYes Then
Call mnuSaveAs_Click
ElseIf Response = vbNo Then
End
UnloadAllForm
ElseIf Response = vbCancel Then
Exit Sub
End If
Else
End
UnloadAllForm
End If
End Sub
this is what will happen when i close the program from the "x-button"
1.)when i click the "x-button".. the Form that display on the MDIForm will invisible... and a msg "do you want to save the file?" will pop up...
2.)when i select "Yes"....a save dialog will pop up.. but once i select "Cancel" from the save dialog... the MDIForm will invisible...
3.)when i select cancel(from the msg).. the MDIForm will invisible also..
if i close the program from the file menu...it work fine..
hope you can follow..
besides, i have another question at here....
why all the comboboxes i have in the program will be highlighted? and how do i prevent this to happen??