dcsimg
Results 1 to 11 of 11

Thread: Loading controls

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2013
    Posts
    4

    Loading controls

    Hey guys,

    Two questions here:

    1) Using the Load Control function, is there a way to save the control so its still there after I close the program?

    So, if there is textbox(0) at design time then textbox(1) is created during run time, the textbox(1) is gone after ending the program. Is there a way to keep it?

    2) I'm making a project and I've got a list of 10 textboxes (indexed from 0 to 9) and a checkbox next to each.

    For a bit of context: these text boxes hold products for a music store, so 1 guitar name is stored in each textbox.

    The checkbox is there to delete one of the textboxes if say, there is no stock left or they do not want it in their store any longer.

    So my code uses a for next loop to check if the checkbox is checked, and if it is, then the textbox unloads, and the textboxes under it successfully move up in its place. However, if i were to delete the 5th textbox (index 4) I get this error:

    Run-time error '340'
    Control array element '4' doesn't exist

    Any and all help will be appreciated. Thanks!

  2. #2

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2013
    Posts
    4

    Re: Loading controls

    Thanks for the response mate.

    Changing it to .visible worked! Thanks a lot, so simple!

    Any ideas for the first question?

  4. #4
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,094

    Re: Loading controls

    @Question 1: Have you thought about using an INI-File for inbetween sessions?
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  5. #5
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Loading controls

    Gooneroo

    Re your 1st question, I have a question .. why would you need to?

    At face value, it seems unnecessary, as it would just be recreated next time you start the app.
    Could you provide a little more in the way of explanation as to why.

    Spoo

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2013
    Posts
    4

    Re: Loading controls

    Zvoni - Not too sure about INI files - what do they do?

    Spoo - I need to add a new item to a list of products (these are in text boxes) as the company now has that item in stock. After closing the form, this item should still be there - they shouldn't need to create it again. Does that make more sense?

  7. #7

  8. #8
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: Loading controls

    Gooneroo

    Yes, that does make more sense.
    Basically, seems like you'd like to enable the app to "remember" custom changes.

    I'll let Zvoni get more into INI files, but essentially they are TXT files.

    You have a couple of alternatives ...
    ... saving "changes" could be in an INI file, a TXT file, or even a database.

    However, you will need to modify your app to enable it to "read" from said TXT file
    and automatically load "saved" values.

    Can you take it from here?

    Spoo

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2013
    Posts
    4

    Re: Loading controls

    Saving the contents of the text boxes is fine for now. However, when I load a new textbox, I need it to stay loaded forever. That's where the main problem lies.

  10. #10
    PowerPoster Zvoni's Avatar
    Join Date
    Sep 2012
    Location
    To the moon and then left
    Posts
    2,094

    Re: Loading controls

    After rereading the thread i think this would be more something for a database in junction with a ListBox (Checkboxes!)
    One System to rule them all, One IDE to find them,
    One Code to bring them all, and to the Framework bind them,
    in the Land of Redmond, where the Windows lie
    ---------------------------------------------------------------------------------
    People call me crazy because i'm jumping out of perfectly fine airplanes.
    ---------------------------------------------------------------------------------
    For health reasons i try to avoid reading unformatted Code

  11. #11
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,283

    Re: Loading controls

    Quote Originally Posted by Zvoni View Post
    After rereading the thread i think this would be more something for a database in junction with a ListBox (Checkboxes!)

    No doubt....'saving stuff' to a database, and then retrieving it at next program run, is easy. Ini files are okay, and creating in IDE and hiding/showing are okay for controls, but to save content of those controls for another session, my choice has always been a db.

    Plenty of examples on this forum to do that.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width