Results 1 to 5 of 5

Thread: Saving user pref's

  1. #1

    Thread Starter
    Junior Member Randy's Avatar
    Join Date
    May 2000
    Location
    Montreal, Quebec, Canada
    Posts
    23
    In program that I am doing for a non-profit org. There are 2 languages being used.

    I have 2 command buttons cmdFrench and cmdEnglish that set all the captions, msgbox, inputbox, lbs, etc the the language clicked.

    (Note: this might not be the right way of doing it but heck, it worked, with alot of typing, were talking 15 forms)

    But the question is how do I get the app to load with the last users default language?

    Also should I put in all the code in the seperate command buttons or use one button with if else. ( I thought that seperate buttons that I would be better able to recall the last language.

    Thanks,
    VB newbie

    Randy

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    ok... here it is:


    Code:
    Private Sub cmdenglish_Click()
    Open "c:\lan.dat" For Output As #1
    Write #1, "English"
    Close #1
    End Sub
    
    Private Sub cmdfrench_Click()
    Open "C:\lan.dat" For Output As #2
    Write #2, "French"
    Close #2
    End Sub
    
    Private Sub Form_Load()
    On Error Resume Next
    
    strItem1 As String
    Open "C:\lan.dat" For Input As #3
    Input #3, strItem1
    Close #3
    
    If strItem1 = "English" Then
    'code for english
    Else
    If strItem1 = "French" Then
    'code for french
    End If
    End If
    End Sub
    NXSupport - Your one-stop source for computer help

  3. #3

    Thread Starter
    Junior Member Randy's Avatar
    Join Date
    May 2000
    Location
    Montreal, Quebec, Canada
    Posts
    23
    Thanks
    So you are saying to put the code in the form load event of form 1, and that the info would be saved in the "lan( or what ever).dat" file.

    Now I know alot of people that have the habit of deleting files on the root drive.

    Is there a way that the file can be saved in the same dir as the app. Not knowing on what drive or the name of the file is to be. This will be done by the user during setup.

    If I have other user prefs to keep, would I put them into the same file?

    Thanks again
    Randy

  4. #4
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    If I were you I would just put it in the windows folder

    "c:\windows\lan.dat"


    but to get it to be in the same folder as your program, I'm just getting this from the top of my head, it might not work:

    Code:
    App.Path & "\lan.dat"
    NXSupport - Your one-stop source for computer help

  5. #5
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Ont, Canada, Earth
    Posts
    458
    Hi,
    I've done apps in different languages and found the Resource file very usefull tool to store the language strings. Check your VB help for how to use resource files.

    Also for storing the last language used consider registry:


    'Declare public var in a module
    Public Language as String

    '------------------------------------------------------
    Sub Form_Load()
    Language = GetSetting("App", "Options", "Language", "E")
    if Language = "E" then
    SetEnglishLanguage
    else
    SetFrenchLanguage
    end if
    End Sub

    '------------------------------------------------------
    Sub Form_Unload()
    SaveSetting "App", "Options", "Language", Language
    End Sub

    Hope that helps
    Thanks

    Tomexx.

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