Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

How to reloan the setting from last time??

hi, i have a question here. i am doing a project with working few forms and database together. My project requests to reload the program when launch next time that had been up to  so how can i remember the data, the page used last time. i might not explained clearly, just give an example:
just like you are playing the games such as AOE, if you save the game, next time when you load the save, you should get back such like what were those people doing, where was working in the map, what level are you in etc. is it request using savesetting & getsetting?? or something else and can provides any example thinks
0
kalok444
Asked:
kalok444
1 Solution
 
TimCotteeCommented:
SaveSetting and GetSetting are probably your best options, these allow you to store the information in the registry and retrieve it. The keys used by these functions in the registry are not exceptionally configurable but are more than adequate for most cases. If not then there are registry functions available that allow even more control and flexibility but you probably don't need this yet.
0
 
kpkpCommented:
if you're after an example, I've used SaveSetting and GetSetting to do something similar:

I has two functions to get and save the info that I wanted to persist.....

Public Function ReadRegistrySettings()

    pstrServerName = GetSetting(conApplication, "Database", "ServerName", "MyServer")
    pstrDatabaseName = GetSetting(conApplication, "Database", "DatabaseName", "MyDatabase")
    pstrUserName = GetSetting(conApplication, "Database", "LastUser", "SA")
    pintMainTop = GetSetting(conApplication, "MainForm", "Top", 105)
    pintMainLeft = GetSetting(conApplication, "MainForm", "Left", 105)
    pintMainWidth = GetSetting(conApplication, "MainForm", "Width", 9400)
    pintMainHeight = GetSetting(conApplication, "MainForm", "Height", 5400)
    pintMainSplit = GetSetting(conApplication, "MainForm", "Split", 4245)

End Function

Public Function WriteRegistySettings()

    SaveSetting conApplication, "Database", "LastUser", pstrUserName
    SaveSetting conApplication, "Database", "ServerName", pstrServerName
    SaveSetting conApplication, "Database", "DatabaseName", pstrDatabaseName
    SaveSetting conApplication, "MainForm", "Top", pintMainTop
    SaveSetting conApplication, "MainForm", "Left", pintMainLeft
    SaveSetting conApplication, "MainForm", "Width", pintMainWidth
    SaveSetting conApplication, "MainForm", "Height", pintMainHeight
    SaveSetting conApplication, "MainForm", "Split", pintMainSplit

End Function


the functions populated some global vars, which were used in various places...

' default user name etc
txtUserName.Text = pstrUserName
txtServer.Text = pstrServerName
txtDatabase.Text = pstrDatabaseName


Private Sub SetFormDimensions()

    ' get form dimensions
    ' from global vars
    frmMain.WindowState = vbNormal
    frmMain.Top = pintMainTop
    frmMain.Left = pintMainLeft
    frmMain.Width = pintMainWidth
    frmMain.Height = pintMainHeight
    tvwMain.Width = pintMainSplit
End Sub


0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now