locked
vb.net 2010 startup form for desktop application RRS feed

  • Question

  • In an existing vb.2010 desktop application, I need to have the users select the vendors they work with plus the access 2013 database file they want to use as input into the application. I need to have the users select these options before they do their normal processing.

    Thus to add this feature to the application, which would you do:

    1. Have a new form setup with only these features, and once these options are selected, have the application then call the existing form that starts the application right now?

    2. Would you add these selections to the existing startup form, and 'gray out' the options the users are used to having? Once the users pick new selections, then enable the original options to work?

     Thus can tell me the following:

    1. Which option you chose and why,

    2. Let me know if can you think of other options that would be good to use in this situation?

    3. Show me the code and/or point me to references that will tell me how to accomplish my goal using the option you selected?

    Thursday, June 4, 2015 3:49 PM

Answers

  • Here's some recursive control search code. You will need to alter it so that an If statement is used to test if Controls Enabled is set to False and if so set to True and if not set to False or something. And it will only need to be run if the User setting is empty or if the User setting is not empty but the database file the user setting accesses no longer exists. And I don't mean no longer exists because the file is on a server but the network may be down. I mean the database file no longer actually exists.

    Update: Also in the below code you would need to determine if the controls happen to be the controls required to allow the user to select a database. Therefore those controls should be named so that you can use in an If statement if the Item.Name <> "Some Control" Or Item.Name <> "Some Other Control" Then check about whether Item.Enabled = True or False I suppose.

    ' In some sub use below code
    
    For Each Item As Control In Me.Controls
           Item.Enabled = False
           GetAllChildControls(Item)
    Next
    
    
    ' Below is recursive control sub
    
    
    
        Private Sub GetAllChildControls(ByVal ctrlParent As Control)
            For Each Item As Control In ctrlParent.Controls
                Item.Enabled = False
                If Item.HasChildren Then
                    GetAllChildControls(Item)
                End If
            Next
        End Sub


    La vida loca


    Thursday, June 4, 2015 5:16 PM

All replies

  • In an existing vb.2010 desktop application, I need to have the users select the vendors they work with plus the access 2013 database file they want to use as input into the application. I need to have the users select these options before they do their normal processing.

    Thus to add this feature to the application, which would you do:

    1. Have a new form setup with only these features, and once these options are selected, have the application then call the existing form that starts the application right now?

    2. Would you add these selections to the existing startup form, and 'gray out' the options the users are used to having? Once the users pick new selections, then enable the original options to work?

     Thus can tell me the following:

    1. Which option you chose and why,

    2. Let me know if can you think of other options that would be good to use in this situation?

    3. Show me the code and/or point me to references that will tell me how to accomplish my goal using the option you selected?

    I would add a user setting that stores the selected database file path or whatever it is that provides link to database.

    Then on first run of updated app check if user setting contains database file info and if not use recursive search to disable all controls in Form except controls used to provide database to use. Then notify user no database selected and advise what to use to select initial database file. Once database file is selected save to setting that information then perform recursive search to enable all controls in Form.

    After that if user setting contains database file to use provide notification on app launch of which database currently selected for use with advisory on how to alter to other database file if desired.

    I would not add another Form to the project just for no real need.


    La vida loca

    Thursday, June 4, 2015 5:03 PM
  • Here's some recursive control search code. You will need to alter it so that an If statement is used to test if Controls Enabled is set to False and if so set to True and if not set to False or something. And it will only need to be run if the User setting is empty or if the User setting is not empty but the database file the user setting accesses no longer exists. And I don't mean no longer exists because the file is on a server but the network may be down. I mean the database file no longer actually exists.

    Update: Also in the below code you would need to determine if the controls happen to be the controls required to allow the user to select a database. Therefore those controls should be named so that you can use in an If statement if the Item.Name <> "Some Control" Or Item.Name <> "Some Other Control" Then check about whether Item.Enabled = True or False I suppose.

    ' In some sub use below code
    
    For Each Item As Control In Me.Controls
           Item.Enabled = False
           GetAllChildControls(Item)
    Next
    
    
    ' Below is recursive control sub
    
    
    
        Private Sub GetAllChildControls(ByVal ctrlParent As Control)
            For Each Item As Control In ctrlParent.Controls
                Item.Enabled = False
                If Item.HasChildren Then
                    GetAllChildControls(Item)
                End If
            Next
        End Sub


    La vida loca


    Thursday, June 4, 2015 5:16 PM
  • Thank you for your answer so far! However I have the following additional questions to ask you:

    1. You stated, " Then on first run of updated app check if user setting contains database file info and if not use recursive search to disable all controls in Form except controls used to provide database to use. Then notify user no database selected and advise what to use to select initial database file. Once database file is selected save to setting that information then perform recursive search to enable all controls in Form." The user is required to select a database path. There will be a default database where it will one selected in a combo box or a list box. Can you show me the code on how to do what I just described?

    Also can you show me the code on what you are suggesting that I do?

    2. You stated, "After that if user setting contains database file to use provide notification on app launch of which database currently selected for use with advisory on how to alter to other database file if desired.". Would you show me the code for the situation you described in this statement me?

    Thursday, June 4, 2015 10:05 PM
  • Thank you for this answer! I do have the additional question to ask you:

    1. I want the database file names to be loaded to a listbox or combo box where the user can select only one file name and there is a default file name. Would you show me the code for that?

    2. Would you show me the code to use on a combo box or list box if the file does not exist, or the network is down?

    3. Would you put the database combo/listbox on the startup form or on a new startup form? Can you tell me what option you chose and show me the code on what to do?

    4. If I put the database list on the startup form, the other options that a user can select right away, should I make the option invisible, not enabled, or both? Can you tell me why you chose that option?

    Thursday, June 4, 2015 10:14 PM
  • Thank you for this answer! I do have the additional question to ask you:

    1. I want the database file names to be loaded to a listbox or combo box where the user can select only one file name and there is a default file name. Would you show me the code for that?

    2. Would you show me the code to use on a combo box or list box if the file does not exist, or the network is down?

    3. Would you put the database combo/listbox on the startup form or on a new startup form? Can you tell me what option you chose and show me the code on what to do?

    4. If I put the database list on the startup form, the other options that a user can select right away, should I make the option invisible, not enabled, or both? Can you tell me why you chose that option?

    I don't have code for these things. I don't have a network with a server running a database server.

    But what I do normally to assist with questions in these forums is research using a search engine. Which significantly reduces time in answering questions rather than waiting for somebody to hopefully come along in a forum and answer a question.

    I would recommend you begin researching information for what you want to know. The internet is a massive information resource. I've no doubt various questions you have already have been answered and have code available on the internet. Although you must learn methods for using search engines, since all vary in some fashion, for producing the desired search engine results.

    You can also try the MSDN Library Search Engine.

    With regard to accessing a database via a network the network could be down, the server that the database engine is on could be down, the NIC card on the PC the user is on could be broken, any number of things that you should learn how to program against. The server PC could even be up but the database engine on it could be offline. I suspect if your app attempts to access a database and the connection can not occur due to various reasons that some error can be caught using a try/catch statement. So on the development machine try accessing a database on a server on a network, turn off the server and try, once the server is running disconnect the NIC's cable to the network and try or disable the WIFI on the development machine if that is how the network is accessed and try. It's up to you to learn enough to do what you need to do. Or waste a lot of time hoping you can ask tons of questions in order to get up to speed, which is time wasting IMO since you can search on your own for info and find it much faster, and at some point it's likely that so many questions will be asked desiring code that everybody will get tired of writing your code for you or searching for you to find code for you.


    La vida loca

    Thursday, June 4, 2015 11:22 PM