|
-
Apr 5th, 2000, 08:21 PM
#1
Thread Starter
Junior Member
I am here to ask how to save a setting in the program rather in a file?
For example, I add a value, say "10" in a blank textbox, is it posible to save the value "10" in the program so that next time when started the program again, the textbox is contain value "10" and not blank? Anyone can help?
-
Apr 5th, 2000, 08:27 PM
#2
Lively Member
You can use the GetSetting and the SaveSetting. This will save to the registry. There are examples in the Help or let me know and I can dig some up.
-
Apr 5th, 2000, 09:29 PM
#3
Thread Starter
Junior Member
What you mean I can find it in help?
Where is the help locate?
Or you can just help me with giving me an example, thianks
-
Apr 5th, 2000, 09:39 PM
#4
What you can do is write to the registry the value of the Textbox when you close your program and read it back when you start the program again:
Code:
Private Sub Form_Load()
Text1.Text = GetSettings("MyApplication", "TextboxValue", "Value", 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSettings "MyApplication", "TextboxValue", "Value", Text1.Text
End Sub
-
Apr 6th, 2000, 01:57 PM
#5
Conquistador
or you can save it to a file:
Code:
'to save
Open "c:\myprog\settings.stn" for append as #1
Write #1, "Hello"
'to open
Open "c:\myprog\settings.stn" for Input as #1
Do Until EOF(1)
Input #1, myString
ListOptions.additem mystring
Loop
-
Apr 6th, 2000, 02:48 PM
#6
Thread Starter
Junior Member
How about different settings?
How about if I have some different seeting in a form,
such as combination of checkboxes, comboboxes, and textboxes?
Is it posibble for me to save the setting in a same file or have to saved it differently?
-
Apr 20th, 2000, 03:27 AM
#7
Junior Member
Better registery....
This is also possible!
Step 1
Download: www.laupro.homepage.com/laupro.dll (Save target as...)
Step 2
Start VB, New project; And go to the menu Project; And than the submenu References
Step 4
Click on Browse and select LauPro.dll
Step 5
Add this code to a new project:
Code:
Option Explicit
Const Reg_Key = "\Software\MyApp"
Const Reg_Key_Caption = "Caption"
Private Sub cmdGet_Click()
Dim LPS As LPStandard
Set LPS = New LPStandard
Caption = LPS.LPGetRegValue(Reg_Key, Reg_Key_Caption, txtCaption.Text)
End Sub
Private Sub cmdSet_Click()
Dim LPS As LPStandard
Set LPS = New LPStandard
LPS.LPSetRegValue Reg_Key, Reg_Key_Caption, txtCaption.Text
End Sub
Download project: www.laupro.homepage.com/reg.zip (Save target as...]
-
Apr 20th, 2000, 08:10 PM
#8
Member
Undocumented...
An undocumented feature of the GetSetting, SaveSetting, and DeleteSetting functions is that you can use paths. For example, to save to HKEY_LOCAL_USER\Software\VB and VBA Program Settings\MyApp\SubFolder\MiniFolder to the key "x" with a value of "2", say:
Code:
SaveSetting App.Title, "SubFolder\MiniFolder", "x", "2"
-
Aug 16th, 2000, 08:58 AM
#9
Lively Member
Originally posted by Serge
What you can do is write to the registry the value of the Textbox when you close your program and read it back when you start the program again:
Code:
Private Sub Form_Load()
Text1.Text = GetSettings("MyApplication", "TextboxValue", "Value", 0)
End Sub
Private Sub Form_Unload(Cancel As Integer)
SaveSettings "MyApplication", "TextboxValue", "Value", Text1.Text
End Sub
Hi there,
Is it possible to save the color settings of the mshflex grid control cells using the savesetting and getsetting functions?
If yes, pls give some ideas.
Thank you.
Rathi
-
Aug 16th, 2000, 06:24 PM
#10
Here's a little example. Add Common Dialog control and MsFlexGrid to your form:
Code:
Private Sub Form_Load()
Dim intRow As Integer
Dim intCol As Integer
With MSFlexGrid1
.Rows = 11
.Cols = 5
For intRow = 1 To .Rows - 1
.Row = intRow
For intCol = 0 To .Cols - 1
.Col = intCol
.Text = "Field" & intCol & intRow
'get saved settings for the color.
'if settings don't exist, then use default colors
.CellBackColor = GetSetting("GridDemo", "Row" & intRow, "Col" & intCol, vbWindowBackground)
Next
Next
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim intRow As Integer
Dim intCol As Integer
With MSFlexGrid1
For intRow = 1 To .Rows - 1
.Row = intRow
For intCol = 1 To .Cols - 1
.Col = intCol
SaveSetting "GridDemo", "Row" & intRow, "Col" & intCol, .CellBackColor
Next
Next
End With
End Sub
Private Sub MSFlexGrid1_DblClick()
With CommonDialog1
.CancelError = True
.ShowColor
If Err.Number = cdlCancel Then Exit Sub
MSFlexGrid1.CellBackColor = .Color
End With
End Sub
By double clicking on any cell in the Grid will let you change it's back color. Then when you close your form, it will save color settings in the registry and use them on next Form_Load event.
Regards,
-
Aug 17th, 2000, 07:07 AM
#11
Lively Member
Originally posted by Serge
Here's a little example. Add Common Dialog control and MsFlexGrid to your form:
Code:
Private Sub Form_Load()
Dim intRow As Integer
Dim intCol As Integer
With MSFlexGrid1
.Rows = 11
.Cols = 5
For intRow = 1 To .Rows - 1
.Row = intRow
For intCol = 0 To .Cols - 1
.Col = intCol
.Text = "Field" & intCol & intRow
'get saved settings for the color.
'if settings don't exist, then use default colors
.CellBackColor = GetSetting("GridDemo", "Row" & intRow, "Col" & intCol, vbWindowBackground)
Next
Next
End With
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim intRow As Integer
Dim intCol As Integer
With MSFlexGrid1
For intRow = 1 To .Rows - 1
.Row = intRow
For intCol = 1 To .Cols - 1
.Col = intCol
SaveSetting "GridDemo", "Row" & intRow, "Col" & intCol, .CellBackColor
Next
Next
End With
End Sub
Private Sub MSFlexGrid1_DblClick()
With CommonDialog1
.CancelError = True
.ShowColor
If Err.Number = cdlCancel Then Exit Sub
MSFlexGrid1.CellBackColor = .Color
End With
End Sub
By double clicking on any cell in the Grid will let you change it's back color. Then when you close your form, it will save color settings in the registry and use them on next Form_Load event.
Regards,
Hi Serge,
Thank you very much for your time and help.
I got stuck with that problem for a couple of days. Thanks a lot.
sincerely,
Rathi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|