Keys corrupted when persisted

Summary

Id: 2.1
Type: Bug Bug
Current Status: Open

Detail

6 Jul 2003 Open Igor

Besides some minor bugs, my customers found one serious bug with in your control and I have fixed it! I am glad that I've fixed this bug because it was hard to repeat it on the computers in my office and I debugged the control "remotely" on computers of my customers. The fact is that that your control raises the error '9' ("Subscript out of range") in compiled applications when you issue the ItemIndex function with a string key of an icon (in VB IDE all is Ok). I place here the full description of this error and our fix, you can also find it and all other bugs fixed by me in the readme_10Tec.txt file in the attached project that contains the fixed version of the control.

The problem is that if you specify string keys for icons, the control stores them in a single string which contains the keys separated by the Chr(255) character. When you launch a compiled (exe) application that contains a vbAccelerator ImageList control with defined icon string keys, the control restores the string with icon keys but replaces the Chr(255) character on Chr(&H3F), the question mark character ("?"), and therefore can not process icon keys properly.

We suppose that this error is caused by the following fact. VB deals with Unicode strings but it stores them in ASCII format in .frm files when you ssue the PropertyBag.WriteProperty method (vbAccelerator ImageList uses it to store the string that represents packed icon keys). Depending on the operating system locale settings the Chr(255) character may be restored properly or not in the corresponding Unicode character; in the last case it is replaced on the question mark character.

To fix this error we changed Chr(255) on the Tab character (vbTab or Chr(9)). This character is saved and restored properly regardless of system locale.