• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 377
  • Last Modified:

VB Savesetting and getsetting for form load????

I am using VB 6 and to do this i understand you have to use the savesetting and getsetting function just im not to sure on these functions.

What i want to do is:     Basic Example

i want to have 2 forms, when you run the program both forms load at once, on form 2 i want to have a check box.  what i want to happen is that when the check box on form 2 is check, when you run the program form 1 dosnt load, i want this setting to save for everytime the program is run until the check box is uncheck then form 1 will load, this must also save. if you understand?

anyone?????

Cheers.
0
On_The_Level
Asked:
On_The_Level
1 Solution
 
vinnyd79Commented:
Try adding this to a bas module and set the Projects startup object to Sub Main:

Sub Main()
Dim rVal As String
rVal = GetSetting(App.EXEName, "Settings", "Form2")
If rVal = "Checked" Then
    Form2.Show
Else
    Form1.Show
    Form2.Show
End If

End Sub

Then try adding this to Form2:

Private Sub Check1_Click()
If Check1.Value = 1 Then
    Call SaveSetting(App.EXEName, "Settings", "Form2", "Checked")
Else
    Call SaveSetting(App.EXEName, "Settings", "Form2", "")
End If

End Sub

Private Sub Form_Load()
Dim rVal As String
rVal = GetSetting(App.EXEName, "Settings", "Form2")
If rVal = "Checked" Then
    Check1.Value = 1
End If

End Sub
0
 
gecko_au2003Commented:
You could also research how to use the fso to write to a text file or ini file and write the settings to that file and determine from the file whether or not to load form1 or form1 and form2 just by reading the values from the text file. That is another way, probably harder then the first though, not sure.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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