Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

save settings to registry

Posted on 2010-11-12
3
Medium Priority
?
288 Views
Last Modified: 2012-05-10
hello there,
I am using this code so save settings of application to the registry..
I just added a TabControl and now its getting an error while saving the data..
its saying Path not found while saving the TextBox what can I do?
Public Sub Save_Settings(ByVal cont As Control, ByVal strName As String)
        For Each thisControl As Control In cont.Controls
            If TypeOf thisControl Is TextBox Then
                SaveSetting(strName, "Settings", thisControl.Name, DirectCast(thisControl, TextBox).Text)
            ElseIf TypeOf thisControl Is CheckBox Then
                SaveSetting(strName, "Settings", thisControl.Name, DirectCast(thisControl, CheckBox).Checked)
            ElseIf TypeOf thisControl Is ComboBox Then
                SaveSetting(strName, "Settings", thisControl.Name, DirectCast(thisControl, ComboBox).SelectedIndex)
            ElseIf TypeOf thisControl Is AxMSComCtl2.AxFlatScrollBar Then
                SaveSetting(strName, "Settings", thisControl.Name, DirectCast(thisControl, AxMSComCtl2.AxFlatScrollBar).Value)
            ElseIf TypeOf thisControl Is RadioButton Then
                SaveSetting(strName, "Settings", thisControl.Name, DirectCast(thisControl, RadioButton).Checked)
            ElseIf thisControl.HasChildren Then
                Save_Settings(thisControl, cont.Tag) 
            End If
        Next
    End Sub

Open in new window

0
Comment
Question by:XK8ER
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 34124568
I don't see how this code is causing the error.  Can you post the stack trace?
0
 
LVL 1

Author Comment

by:XK8ER
ID: 34124622
when I get the error It marks this line as yellow

SaveSetting(strName, "Settings", thisControl.Name, DirectCast(thisControl, TextBox).Text)

and says "Argument 'Path' is Nothing or empty."

when I put the mouse over
Public Sub Save_Settings(ByVal cont As Control, ByVal strName As String)

it says cont TabPage = Dogs and strName = Nothing

maybe that nothing is causing the issue? did you tried the code?
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 34124667
Well...at the bottom of your If structure you have this:

            ElseIf thisControl.HasChildren Then
                Save_Settings(thisControl, cont.Tag)
            End If

You're making a recursive call to Save_Settings() but the second parameter is using the TAG() of the current control.  I'm guessing you have controls that do NOT have anything in the Tag() property and this is causing the error as "strName" is being used as the first parameter to SaveSetting().

You said you added a TabControl.  Did you put something in the Tag() property of each TabPage?
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question