FlexGrid not sorting/exporting during entering values

I have the attached project.  When I enter a new website name it prompts me to enter into the grid in blue.  After entering the value, it only works if I click on another row.  However, when I push the enter key to accept the value, it does not work.  i would like to also push the enter key and allow the same execution as when I click on another row.
CB.zip
al4629740Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
This should allow you to use Enter. In addition to that you should use Notepad to remove all ^(.*\.)?\.$ entries from the file.
Q-28571318.zip

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
al4629740Author Commented:
Thank you!
Martin LissOlder than dirtCommented:
I'm glad I've been able to help you. If you come across any bugs, post them here rather than a new question and I'll be happy to do what I can.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

al4629740Author Commented:
Martin,

I have to make sure that blanks fill ins do not happen on the flexgrid.  For example, if I click Add New and then "decide" not to enter any website, I have a dilemma.  Then I have to push Esc and then find a blank line.  

As a result I get   ^(.*\.)?\.$  

This produces a blank and no blanks should ever exist in the file.

Should I open a new request to fix this?
Martin LissOlder than dirtCommented:
No, I'll take care of it.
al4629740Author Commented:
Thank you
Martin LissOlder than dirtCommented:
I'm also going to add more validation for the website name, because now for example you can enter "aa   aa.com" and get away with it. No new question needed.
al4629740Author Commented:
Perfect!!

Yes the format only needs to be website.com
Not www.website.com
Martin LissOlder than dirtCommented:
Please see this short article. I'd like to validate the length of the website name and I assume you want it to be 63 characters or less, but apparently it can be longer. Please let me know what length I should use.

BTW I thought that the "domain" was the part following the last dot, like ".com", but apparently not. Can you tell me what that part of the name is called?
Martin LissOlder than dirtCommented:
I also found this quote, so I'm happy to add full validation, but I need your guidance as to what I should validate.
Each label may contain up to 63 characters. The full domain name may not exceed the length of 253 characters in its textual representation
Martin LissOlder than dirtCommented:
BTW I thought that the "domain" was the part following the last dot, like ".com", but apparently not. Can you tell me what that part of the name is called?
I answered my own question here, it's the "top-level domain".
al4629740Author Commented:
correct, they are called top level domain

btw, the link is in error.  Can you take a look at it
al4629740Author Commented:
But I see your point anyways.  You are right, domain names do not exceed 63 characters.  So validation only needs to occur at that maximum 63 and at least 2 minimum
Martin LissOlder than dirtCommented:
Does the 63 include ".com", etc?
al4629740Author Commented:
I believe not
Martin LissOlder than dirtCommented:
I'm calling it a night and I may not have a lot of time tomorrow but I won't abandon you.
al4629740Author Commented:
Thanks Martin.  I'm patient : )
Martin LissOlder than dirtCommented:
It didn't take as long as I thought it would. This update includes:
Allow Enter to be used to signal completion of the Add Record process
Corrected a bug where when the user changes his mind about adding a new record and presses Esc, a blank record results
Added more website name validations
Disabled some buttons when appropriate
Added a caption to the form
Improved the unsaved changes warning
Here's a heads-up on the last one. The old message which was this
oldbothered me since it was added because it was worded awkwardly and I thought a little confusingly, so I changed it to this. I hope you approve but if not it's easy to undo. Note that the buttons now do the opposite of what they did before.
newQ-28571318-2.zip
al4629740Author Commented:
I will try it when I get home later today.  Thank you
al4629740Author Commented:
Martin.  Great changes!

I noticed one thing.  When I add a record and then change my mind by pushing Esc, then all the buttons are remain disabled and lock me out from doing anything.

See if you get the same issue.  Maybe I'm doing something wrong.
Martin LissOlder than dirtCommented:
You're probably right. Be back later.
Martin LissOlder than dirtCommented:
Mia culpa. I made the command button changes at the last minute and obviously didn't fully test.
Q-28571318-3.zip
al4629740Author Commented:
gratias ago tibi
al4629740Author Commented:
I reluctantly want to ask for another correction because I would rather just open another question.  

When selecting more than one site using the shift key, I attempt to delete multiple records and get an error.  I think it might be good to just only allow one site to be deleted at a time and this will simplify things.  Should I open another question?

Again thank you for your persistence and help.  You have gone above and beyond.
Martin LissOlder than dirtCommented:
Let me think about this for a while.
Martin LissOlder than dirtCommented:
There's no built-in way to limit the number of selected rows to one. I've seen some code on the web that purports to do that but I haven't used any of them and I don't know if they would affect the existing code. There is also no built-in way to know how many rows are selected but I've seen and used code that will allow that to be determined. So we can either try to limit the selection to one row or attempt to allow multiple, contiguous, rows to be deleted. If the latter is your choice then I'd prefer a new question, if you choose the former then I can do it here or in a new question. In either case  (and even if we do neither) we probably should delete the header in the output file if after deletions it has no more websites under it, right?
al4629740Author Commented:
Deleting one row would be easier and probably cleaner.

Yes, the header could go away, but could also remain to see that there was history there before.
Martin LissOlder than dirtCommented:
Okay so if you accidentally or on purpose select more than one row how do you want it handled? I  could just reject the selection and say essentially "try again" or I could tell you that I recognize that you've selected more than one but that I'm only going to delete the first one, or...?
al4629740Author Commented:
Maybe just a message box that says, "only one website can be selected at a time"
Martin LissOlder than dirtCommented:
In addition to the message I coded it so that the program continues with the deletion of the first row selected. If you'd rather just make the single row selection manually then change

If intEndRow - intStartRow <> 0 Then
    MsgBox "Only one website may be selected at a time", vbInformation + vbOKOnly, "Website Selection Error"
    MSFlexGrid1.RowSel = intStartRow
    'Exit Sub
End If

Open in new window

to this in cmdDelete_Click.
If intEndRow - intStartRow <> 0 Then
    MsgBox "Only one website may be selected at a time", vbExclamation + vbOKOnly, "Website Selection Error"
    MSFlexGrid1.RowSel = intStartRow
    Exit Sub
End If

Open in new window

Q-28571318-4.zip
al4629740Author Commented:
Thank you Martin.  

When the "Website Selection Error" executes, after clicking OK, then  cmdDelete_Click()  still executes.  Is it possible to prevent cmdDelete_Click() from executing if the "Website Selection Error" is triggered?
Martin LissOlder than dirtCommented:
When you see the "Pending Deletion" message that follows the "Website Selection Error", just click Cancel rather than OK.
al4629740Author Commented:
Thats true, but it might get confusing if the user sees OK as an option.  

Is there a way to prevent that from happening on cmdDelete_Click()  so that if there is more than one selection, it simply does not occur?

I think this might be another question to ask?
Martin LissOlder than dirtCommented:
Change the code as I suggested in post ID: 40472548.
al4629740Author Commented:
Ahhh.  I should have notice that.  Thanks again!
Martin LissOlder than dirtCommented:
YW. I'd like to do one more thing before we're done. Right now the program makes note of any change that is made to the list of websites (by setting a flag) and gives a warning about unsaved changes if the flag has been set. It also however records things like starting to add a new record but changing your mind as a change, and that would result in a false warning message if that were the only "change" made.  I realized after I did that that a much better way would be to just save a list of the websites when they are initially loaded and when exiting to compare the saved list to the list that was going to be Exported, and if there's any difference display the warning. That will eliminate the false "change" that I referred to earlier. Would you like me to do that?
al4629740Author Commented:
Martin,  

Thanks for noticing the details.  If possible, could you please do that?  
Another question?
Martin LissOlder than dirtCommented:
Not necessary.
Q-28571318-5.zip
al4629740Author Commented:
Martin,

Test the project again and see if you get an error on the double click event
Martin LissOlder than dirtCommented:
My apologies. Before I fix that I have a few things I want to ask you about.
1.    If the user double-clicks a row making it blue, changes the text and then clicks the "X" (without having pressed Enter or selecting another row), should that trigger the "unsaved changes" warning?
2.    If the file contains ^(.*\.)?hsd1.il.com.comcast.net$, what do you want to see on the screen? In other words what is editable? It would be easier if it were always hsd1.il.com.comcast.net or always comcast.net. If it is the latter, is there always just one dot?
3.    California has a lot of sites like http://www.blah.ca.gov (all ending in ca.gov). If that site were in the allowed list, would it look like ^(.*\.)?blah.ca\.gov$ or would it look like  ^(.*\.)?blah\.ca.gov$? What I'm asking is if there can be more than one dot in the part following the "\" in the allowed website records.
al4629740Author Commented:
Martin,

I just saw your message.  Thanks for the follow up.

You made me think about another question.  Let me find out about #2 and #3 and get back to you soon on this post

Al
al4629740Author Commented:
Martin,

1) When I double click a row, I get an error.  Could you see it if you get an error on the double click event?

2) hsd1.il.com.comcast.net should be listed on the flexgrid.  

3)  It should actually be written as ^(.*\.)?blah\.ca\.gov$

I just learned that all regex statements should be \.  in place of .
So hsd1.il.com.comcast.net above would be written also as ^(.*\.)?hsd1\.il\.comcast\.net$
Martin LissOlder than dirtCommented:
1) When I double click a row, I get an error.  Could you see it if you get an error on the double click event?
You reported that as a problem in post ID: 40473055 and in post ID: 40474083 I said I'd fix it, but before we get to that I want to clear up the design.

2) hsd1.il.com.comcast.net should be listed on the flexgrid.
I interpret that to mean that everything to the right of the question mark in all entries should be shown and editable.

So hsd1.il.com.comcast.net above would be written also as ^(.*\.)?hsd1\.il\.comcast\.net$
Does that mean the the input will be like that, or do you just want it to be written out like that?
al4629740Author Commented:
1) Ok

2) That is correct.  everything to the right of the question mark.

3)  The previous way works fine.  But I learned that to be exactly correct, every period to the right of question mark should be \.  instead of . when it is written back to the allowed file.

Hopefully I explained it.  Let me know if I need to clarify more.
Martin LissOlder than dirtCommented:
I understand that the output should be \. but will the input be that way?
al4629740Author Commented:
Yes, it should be.  The original file I gave you incorrectly had it written.
Martin LissOlder than dirtCommented:
This app was developed piecemeal and as a result it's messy, so I'm rewriting it. It may take me a day or two to do it and to test it thoroughly.
al4629740Author Commented:
Martin

Much appreciated!!!!
Martin LissOlder than dirtCommented:
It just dawned on me that the "Import" button isn't needed and that when the program starts its should  just open the file, so I'm going to delete that button.
al4629740Author Commented:
Good Point.
Martin LissOlder than dirtCommented:
OK, here's the new version. Testing included:
Adding a record
Make sure ";ALLOW_MISCELLANEOUS_r<date>" header is added when adding a record
Make sure a header for a given day is added only once
Changing mind during add via the esc key
Adding multiple records (one at a time)
Add a record and then change it
Add a record and then delete another record
Delete a record
Try to delete more than one at the same time
Delete two records, one at a time
Change a record
Change mind during change
While I feel that I've thoroughly tested it, I encourage you to do the same. And if you do then please hold up on reporting problems until you are finished testing.
Rewrite.zip
al4629740Author Commented:
I will test it tonight.  I may need help on the BlockedSite form also in a separate question

Thank you!!
al4629740Author Commented:
Very good.  Couple issues I found after messing with it for some time.

1) When entering a website name without a top-level domain such as "test", it gives the message : This website must have a top-level domain.  But after if you click on the cell, the field accepts the invalid site as "test".  Instead can it simply stay in "blue box mode" until corrected?  Or any other way to fix it.

2) If I type add another website with the same name, it gives me the message box that I can't, but still allows the entry to be accepted after clicking OK.  Can this also stay blue until corrected?

3) If I double click a row to edit the website and then change my mind by clicking on another row, it gives me the error that this website already exists.  When I click on a different row, it correctly shows the same error again.  After that, if I double click on another row, it adds a duplicate website name. (I doubt this will be a real issue, but I'm really trying to stress test this.  The issue might be resolved by adding, "Push Esc to leave this record")

3) Export should probably say "Save Changes" instead
Martin LissOlder than dirtCommented:
Hope this does it.
Rewrite-1.zip
al4629740Author Commented:
LOOKING GOOD!
Martin LissOlder than dirtCommented:
That's GOOD:) Can you give me a heads up on the help you need on the BlockedSite form, and let me know how this form relates to that one?
al4629740Author Commented:
Sure, let me post up a new question
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.