CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2000
    Location
    Pa
    Posts
    3

    Errors Abound when creating menus at runtime

    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.


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Errors Abound when creating menus at runtime

    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
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured