Click to See Complete Forum and Search --> : Errors Abound when creating menus at runtime


Scott123
February 16th, 2000, 03:21 PM
I am allowing the user to add menu items at runtime. The first problem is that the menus are not saved after the app closes. I overcame that by writing to a flat file and recreating them on form load. The second problem is I was using a random number for the index, now when it hits a number that was previously used it gives me the error that the object is already loaded, yet I cannot access any properties. Trying to debug I threw a For..Each..Next loop in the main forms activate event based on all items in the menu array. I hardcoded an index that I knew had been used. Outside the loop I assigned the visible property to true. When I ran the code the loop returned true(saying it found the index), then I recieved an error saying that the index value was not part of the control array(the visible statement) Any help would be appreciated. Thanks in advance.

Johnny101
February 16th, 2000, 03:30 PM
why not use

dim x as integer
x = ubound(mnuArray) + 1
load mnuArray(x)
mnuArray.visible = true



to load the new items into the array? this might eliminate the possibility of generating the same number using the rnd function.

Hope this helps/applies,
John

John Pirkey
MCSD
www.ShallowWaterSystems.com