[Gambas-user] Safety for collections
T Lee Davidson
t.lee.davidson at gmail.com
Wed Aug 23 21:11:49 CEST 2023
On 8/23/23 14:05, Fabien Bodard wrote:
> I don't if it is what you mean... for the modified flag it can be in a parallel collection that handle a boolean.
> Le mar. 22 août 2023 à 18:55, T Lee Davidson <t.lee.davidson at gmail.com <mailto:t.lee.davidson at gmail.com>> a écrit :
> Perhaps use a global boolean as a semaphore to indicate if the ObjectName field has been changed (using, of course, the
> TextBox's Change event).
> Upon clicking "Save", if the name has been changed, then logic would say the user is attempting to Add a new name. So then
> to see if the new name already exists and, if so, pop up a form listing similar, existing names so they can create a name that
> does not exist; or simply let them enter a new name and click a "Check" button which would repopulate the form.
> The form popped up should have a "Cancel" button that would set the semaphore to False. A successful save should also reset the
> Fabien Bodard
No, that's not exactly what I meant. I meant use a (Public or Private) boolean with Class or Module scope, for example:
Public bNameChanged as Boolean
Public Sub txtObjectName_Change ()
bNameChanged = True
Then when "Save" button is clicked:
Public Sub btnSave_Click()
If bNameChanged Then
' Check if name already exists and act accordingly.
And, I think that checking if the object name already exists at *every* Change event might be annoying to the user that hasn't
even entered the complete name yet.
More information about the User