Best way to add a default and how to call a file.

Posted on 2005-04-27
Last Modified: 2010-05-02
I know this is subjective but when I get the answer you will get a Grade of an A.

I have a app that has someone put in their username and password and also asks for their department.  I know that they will be installing this on their machines so I want it to default to the department that they last used.

What is the BEST way to do this?

Also I would like to be able to update the department list and NOT have to send them a NEW file since I know they will be connecting to work is there a way I can either call a file on a webserver or something like that?

What is the BEST way to do this?

In case you are wondering what tool I am building... I am simply making a tool so that when a person puts in their login and password I can map their drives on their personal machine to the drives at work.  

Even though I feel these questions are NOT difficult for you EXPERT VB Programmers I am in a hurry to get the answer so I am starting with 500 points.

Thanks for all the help you give.

Question by:nathans
    LVL 52

    Expert Comment

    by:Carl Tawn
    The best way to retain the last department the user selected is to store the info in the registry.

    Personally, if I wanted update the department list in the way you want I would use an XML file on a webserver and take the info from that. You can then either use the XML file to retrieve the departments everytime, or simply use its contents to create a file on the users local machine.

    Hope this helps.
    LVL 5

    Author Comment

    I am VERY new to VB so I figured a XML file might be best... but what I want is some help in the coding of how to do it...

    also does it have to be in the Registry... not sure I want to play in there?

    or is that something safe and easy?

    LVL 16

    Accepted Solution

    To elaborate on carl_twain's answer, I agree, the best way to implement a 'last department' default is with the registry.  The simplest registry implementation is (in a 'login' form):

         Private Sub Form_Load()

             txtUser.Text = GetSetting("Your_App_Name", "Startup", "LastUser", "")
             txtPassword.Text = ""
             txtDepartment.Text = GetSetting("Your_App_Name", "Startup", "LastDepartment", "")

         End Sub

         Private Sub Form_Unload()

             SaveSetting "Your_App_Name", "Startup", "LastUser", txtUser.Text
             SaveSetting "Your_App_Name", "Startup", "LastDepartment", txtDepartment.Text

         End Sub

    As for getting an update, you're always going to have to send the data to them somehow, be it a file or an XML stream.  I guess the best steps would be:

         (1)  Check if there is an internet connection
         (2)  Check the on-line file version against off-line version
         (3)  If versions are different, download the file
         (4)  Read from the file



    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now