Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


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

Posted on 2005-04-27
Medium Priority
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
ID: 13878585
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.

Author Comment

ID: 13878615
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

jimbobmcgee earned 2000 total points
ID: 13878761
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

580 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