|
-
Jul 26th, 2000, 12:11 PM
#1
Thread Starter
Fanatic Member
I have a program that has a tabstrip with 6 topics, and for each topic there is a frame that my controls are set in. I use the frames right now to determine if the button are visible or not.
For each frame I have between 1 to 6 command buttons place.
I do not need all of the buttons all of the time. My code is not that big and as of right now not a big memory hog. I am trying to plan for the future by learning the "right way" now.
All of the buttons are the same except for a few things:
Location on the form
What frame they are in
Caption
Click event runs a different sub
Right now the buttons are individual buttons that I created a design time. This I assume takes the most memory to do.
I have be contemplating making the buttons either a control array at design time or create the buttons on the fly as a user selects the tab that they are on.
The final outcome I would like is a less confusing code with all of these button and for the program to use as little memory as possible.
Do you have any opinions?
Thanks
-
Jul 26th, 2000, 12:20 PM
#2
Personally i would make them a control array at design time.
you can always use a select...case block to find out which button was pressed and insert code as necessary.
I wouldnt worry too much about memory consumption if your only concern is how to create a few command buttons, not much memory overhead is attributable to this.
-
Jul 26th, 2000, 12:34 PM
#3
Thread Starter
Fanatic Member
Originally posted by wossname
I wouldnt worry too much about memory consumption if your only concern is how to create a few command buttons, not much memory overhead is attributable to this.
The command button was only an example. I will have a couple of treeviews, labels and textboxes. I am just trying to plan ahead for the future for when I get good at this.
Does the control array use less memory at design time?
Thanks,
-
Jul 26th, 2000, 12:39 PM
#4
I agree with wossname. You can also use Enums to make the select case self-documenting as in this example that assumes a control array that contains 3 buttons.
Code:
Option Explicit
Public Enum MyButtons
btnOpen = 0
btnDoIt = 1
btnExit = 2
End Enum
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case btnDoIt
' Do DoIt processing
Case btnExit
' Do Exit processing
Case btnOpen
' Do Open processing
End Select
End Sub
-
Jul 26th, 2000, 01:09 PM
#5
Thread Starter
Fanatic Member
Martin, I like your suggestion. I would like to try to take this one step further.
Can you /should you create a command button so that only one shows up in the property list? (to keep it simple) I would also like to have all of the same properties as the original control except what I mentioned above.
One way I was thinking of doing was something like below. I know the code is not correct. I'm grasping here.
Code:
Dim NewCmd As Command1
Set NewCmd = New Command1
With NewCmd
.Caption = "New Button"
' Whatever else I want to add
End With
If I add in the control like above how can I have it so that it becomes associated with a certain frame, so that when I hide the frame the control is also hidden?
[Edited by steve65 on 07-26-2000 at 02:38 PM]
-
Jul 26th, 2000, 08:20 PM
#6
Don't worry about the number of entries in the property list.
If you want to create a control at runtime that is exactly like an existing control, see my response in this thread http://forums.vb-world.net/showthrea...threadid=24097
If the control you create is based on a control that's in the frame, the created control will also be in the frame and will become invisible if the frame is made invisible.
-
Jul 27th, 2000, 03:58 AM
#7
Well ....
Let me beat the remaining horse.
steve65, I am concentrating on a different aspect of your project design. You have different frames with an almost similar set of buttons on each frame, is that right?
What I suggest is you create the buttons outside any frames, on the form itself. Thus there will only be one set of buttons, on your form. Now in the Click() event of the buttons you put code such that it detects which frame is on top and acts accordingly.
-
Jul 27th, 2000, 06:42 AM
#8
Thread Starter
Fanatic Member
Screen Shots?
Marty & HoneyBee,
I understand everything you are saying and thank you for all of your help.
I am just not sure how to apply the information you have given me to my particular project. The main reason is because I work in such a vacuum here and am the only programmer, I do not know what the accepted practice is in the industry concerning form design. I could very well take the suggestions that you offered and fly but I am such a perfectionist that before I go any further on the form design and before the program gets any more complicated I would like to have the form built the most efficient way.
If you don't mind I would love to send you a couple of screen shots of the form so that you know what I have done so far. Please send me your email address if this is OK.
Thanks again!
-
Jul 27th, 2000, 09:58 AM
#9
My email address (and in the same way, many other people's email adresses) can be found by clicking the profile button below a post from me. You can also mail anyone by clicking the mail button.
-
Jul 27th, 2000, 10:22 AM
#10
Thread Starter
Fanatic Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|