Start New Discussion within our Software Development Community

Hi all,
I want to save some form setting at registry,
my friend told me that vb has a function to save it..
what it is? and how to use it?

Please Help

@Jx_Man : can you show me an example code? please..
@Debasisdas : i already open the link that you provide to me, but that for visual studio 2005. is this compatible with vb6?

Yes it is.

please try this sample.

SaveSetting Your_Application_name.EXE, "textboxes", "text1", text1.Text
SaveSetting(App.EXEName, "Textboxes\frmMain", "Text1", frmMain.Text1.Text)

code in debasisdas link is for vb2005 but SaveSetting have same way to use in vb6.
there are sample code too in debasisdas link.

See if this help :

' Save form settings

Function SaveFormSettings(ByVal AppName As String, frm As Object)
    SaveSetting AppName, frm.Name, "Left", frm.Left
    SaveSetting AppName, frm.Name, "Top", frm.Top
    SaveSetting AppName, frm.Name, "Width", frm.Width
    SaveSetting AppName, frm.Name, "Height", frm.Height
    SaveSetting AppName, frm.Name, "WindowState", frm.WindowState
End Function

' Restore form settings.

Function LoadFormSettings(ByVal AppName As String, frm As Object)
    Dim currWindowState As Integer

    ' in case no value is in the registry
    On Error Resume Next

    ' If the form is currently maximized or minimized, temporarily
    ' revert to normal state, otherwise the Move command fails.
    currWindowState = frm.WindowState
    If currWindowState <> 0 Then frm.WindowState = 0
    ' Use a Move method to avoid multiple Resize and Paint events.
    frm.Move GetSetting(AppName, frm.Name, "Left", frm.Left), _
        GetSetting(AppName, frm.Name, "Top", frm.Top), GetSetting(AppName, _
        frm.Name, "Width", frm.Width), GetSetting(AppName, frm.Name, "Height", _
    frm.WindowState = GetSetting(AppName, frm.Name, "WindowState", _
End Function

' Delete form settings

Sub DeleteFormSettings(ByVal AppName As String, frm As Object)
    DeleteSetting AppName,
End Sub

Using these routines is straightforward:

Private Sub Form_Load()
    LoadFormSettings "MyApp", Me
End Sub

Private Sub Form_Unload(Cancel As Integer)
    SaveFormSettings "MyApp", Me
End Sub
Thanks for completed answer
This question has already been answered. Start a new discussion instead.