Results 1 to 10 of 10

Thread: Beating a Dead Horse

  1. #1

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Unhappy

    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
    This space for rent...

  2. #2
    Guest
    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.

  3. #3

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    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,
    This space for rent...

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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

  5. #5

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    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]
    This space for rent...

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    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.


  7. #7
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    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.
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  8. #8

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610

    Lightbulb 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!
    This space for rent...

  9. #9

  10. #10

    Thread Starter
    Fanatic Member steve65's Avatar
    Join Date
    Jun 2000
    Posts
    610
    They are on their way.
    This space for rent...

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