R
Rob W
Greetings,
I am designing a simple notepad in vb.net (visual studio 2008) for an
assignment.
Initially I thought to use the textbox "TextChanged" event, which I could
then set a global variable of type boolean "Changesmade" to
monitor if a document needs to be saved based on if any text changes have
been made.
Shortly after I realised anytime a document was opened or a new document
initalised this triggered the textbox "textchanged" event.
I then introduced another global variable of type boolean
"DocumentOperation" which would be set to true when a document operation
such as new file or open file had been actioned.
This code allowed to track changes within the textbox ONLY after the initial
document had been opened or initialised (see code below):-
'Ensure changesmade flag is only set when text is changed on a new or opened
document
'and not on an initial opening or creation of document
If DocumentOperation = True Then
DocumentOperation = False
Else
'Set the ChangesMade variable to TRUE as the user has made some change
to the document
ChangesMade = True
End If
To summarise the code above tracks if any changes have been made to the
document to allow the ChangesMade variable to be used to prompt the user to
save the current document on a New, Open or Exit action.
As there are always more than one solution are there any inbuilt methods or
other solutions that are more efficient than the one I choose?
Thanks
Rob
I am designing a simple notepad in vb.net (visual studio 2008) for an
assignment.
Initially I thought to use the textbox "TextChanged" event, which I could
then set a global variable of type boolean "Changesmade" to
monitor if a document needs to be saved based on if any text changes have
been made.
Shortly after I realised anytime a document was opened or a new document
initalised this triggered the textbox "textchanged" event.
I then introduced another global variable of type boolean
"DocumentOperation" which would be set to true when a document operation
such as new file or open file had been actioned.
This code allowed to track changes within the textbox ONLY after the initial
document had been opened or initialised (see code below):-
'Ensure changesmade flag is only set when text is changed on a new or opened
document
'and not on an initial opening or creation of document
If DocumentOperation = True Then
DocumentOperation = False
Else
'Set the ChangesMade variable to TRUE as the user has made some change
to the document
ChangesMade = True
End If
To summarise the code above tracks if any changes have been made to the
document to allow the ChangesMade variable to be used to prompt the user to
save the current document on a New, Open or Exit action.
As there are always more than one solution are there any inbuilt methods or
other solutions that are more efficient than the one I choose?
Thanks
Rob