-
Ok I am having problems saving some button setups to the registry. In the button to save it to the registry I have this
SaveSetting App.Title, "Settings", "buttontag", pvarButton.Tag
SaveSetting App.Title, "Settings", "buttontooltiptext", pvarButton.ToolTipText
SaveSetting App.Title, "Settings", "buttoncaption", pvarButton.Caption
the pvarbutton stuff is some things I did to make the coding easier for some other stuff
in the load button i have this
On Error Resume Next
pvarButton.Tag = GetSetting(App.Title, "Settings", "buttontag")
On Error Resume Next
pvarButton.ToolTipText = GetSetting(App.Title, "Settings", "buttontooltiptext"
On Error Resume Next
pvarButton.ToolTipText = GetSetting(App.Title, "Settings", "buttoncaption"
but i do not see the problem in it
if you can help please do so
-
You were almost there... Try this instead. I've simplified it a bit and but an error handler in so that if it is returning an error you can let us know what it is:
Private Sub LoadSettings()
On Error GoTo err1
pvarButton.Tag = GetSetting(App.Title, "Settings", "buttontag")
pvarButton.ToolTipText = GetSetting(App.Title, "Settings", "buttontooltiptext")
pvarButton.Caption = GetSetting(App.Title, "Settings", "buttoncaption")
Exit Sub
err1:
MsgBox Err.Number & ":" & vbCrLf & Err.Description, vbCritical, "Error"
End Sub
Private Sub pvarButton_Click()
On Error GoTo err2
SaveSetting App.Title, "Settings", "buttontag", pvarButton.Tag
SaveSetting App.Title, "Settings", "buttontooltiptext", pvarButton.ToolTipText
SaveSetting App.Title, "Settings", "buttoncaption", pvarButton.Caption
Exit Sub
err2:
MsgBox Err.Number & ":" & vbCrLf & Err.Description, vbCritical, "Error"
End Sub
-
ok i put in that exact coding
and it seems to save it fine... i guess
but when i go to load them it brings up an error
Error
91:
Object variable or With block variable not set
-
ok if i keep the program runnning it will load them fine, but if i close the program and try to load them again it doesnt work
-
Does it give the same error? or does your own customized error box pop up?
-
the same error comes up
but it loads them if i dont close the program but if i close the program it brings up the error when i try to load them
-
What version of VB are you using? I've been using this code for a long time and I've never seen the error in this place before...
-
-
I'm really not sure what is wrong. Let me look around a bit and see what I can find.
-
ok
i dont see what the problem in it could be though
i thought for sure mine should have worked, but it didnt and then theres a problem in yours
this is just all messed up
-
Try this code... last param is default, in the case that the registry settings you are extracting doesn't exist the default value is used!
Private Sub LoadSettings()
On Error GoTo err1
pvarButton.Tag = GetSetting(App.Title, "Settings", "buttontag", "Open File")
pvarButton.ToolTipText = GetSetting(App.Title, "Settings", "buttontooltiptext", "Click to open a file")
pvarButton.Caption = GetSetting(App.Title, "Settings", "buttoncaption", "&Open")
Exit Sub
err1:
MsgBox Err.Number & ":" & vbCrLf & Err.Description, vbCritical, "Error"
End Sub
Private Sub pvarButton_Click()
On Error GoTo err2
SaveSetting App.Title, "Settings", "buttontag", pvarButton.Tag
SaveSetting App.Title, "Settings", "buttontooltiptext", pvarButton.ToolTipText
SaveSetting App.Title, "Settings", "buttoncaption", pvarButton.Caption
Exit Sub
err2:
MsgBox Err.Number & ":" & vbCrLf & Err.Description, vbCritical, "Error"
End Sub
-
Thanks, I hope this works, but I can't try right now because im in school, but as soon as I get home I am gonna try that code. Thank you both for helping me. Like I said I hope this works, but I can't try now because im in school. Thanks Again.
-
Sorry privoli. That didn't work. I don't know what could be wrong with this thing. It's like nothing will work. I don't know how many different things I've troed, and none of them work.
If anybody else can help please do.-