Current location - Recipe Complete Network - Complete cookbook - Design of VB dynamic menu
Design of VB dynamic menu
You cannot name the dividing line mcfile(0) in the menu. Every time I say the name is wrong, I can only call it mcfile. But after this name, clicking "Add Menu Item" can't achieve the effect given by the title, and the menu can't display "File 1".

-

You cannot use parentheses in the name entered in the menu editor.

Parentheses like this in the name indicate an array of controls, so you can directly enter the name? mcfile? , fill in the index office? 0? Just (as shown)

Besides, there is something wrong with the code you gave. Dim? mcont? As? Integer? In the process, it means that this variable is an ordinary variable. If you don't save it after this click event, the next time you execute this event, it will be zero, and the function of gradually adding menus will not be realized. Can you play it? Dim? mcont? As? Integer? Change to? Static electricity mcont? As? Integer, here? Static electricity Show? mcont? Is a static variable, its function is to keep the value of the variable at the last exit when it is executed again, namely:

Private? Sub? Command 1_Click()

Static electricity mcont? As? integer

mcont? =? mcont? +? 1

mcfile(0)。 Visible? =? real

Load? mcfile(mcont)

mcfile(mcont)。 Title? =? "File"? & amp? Str(mcont)

End? submarine