Solved

Save setting code with VB2010

Posted on 2011-02-19
10
1,430 Views
Last Modified: 2012-06-22
Hello all

I had this code in VB6 that was working but if i do the same thing with Visual Studio 2010, it does not work:

SaveSetting("MyApp", "Settings", "TexttxtBaseDelabsolution", Form2.txtBaseDelabsolution)

Open in new window


It say NullRefrenceException was unhandled.


What could be the issue.

Thanks again for your help.
0
Comment
Question by:Wilder1626
[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
  • 5
  • 3
  • 2
10 Comments
 
LVL 8

Expert Comment

by:jimsweb
ID: 34933104
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34933193
I see that this is for VB Net

Is this the same for Visual Basic classic?
0
 
LVL 8

Expert Comment

by:jimsweb
ID: 34933211
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 76

Expert Comment

by:GrahamSkan
ID: 34933217
Try specifying the text property of the text box.

SaveSetting("MyApp", "Settings", "TexttxtBaseDelabsolution", Form2.txtBaseDelabsolution.Text)
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34933422
Hello GrahamSkan

No sorry, even with the .Text, still the same issue.
0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34933519
it is saying: System.NullRefrenceException (Variable object or variable of the bloc With not define)

 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        SaveSetting("MyApp", "Settings", "TexttxtBaseDelabsolution", Form2.txtBaseDelabsolution.Text)
    End Sub

Open in new window

0
 
LVL 11

Author Comment

by:Wilder1626
ID: 34933997
I just found out the error:

This is the good syntax:
 SaveSetting("MyApp", "Settings", "TexttxtBaseDelabsolution", Me.txtBaseDelabsolution.Text)

Open in new window


Thanks for your help again.

Have a good day

0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 34934108
I have tested that with VB2010 and it works for me. Are you sure that Form2.txtBaseDelabsolution exists?
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 34934118
Oops, sorry. I didn't see your last comment.

I had put the code in Form1, and the textbox in Form2. Presumably you had the code in Form2. For some reason, you can no longer refer to the containing form by its name, but you must use the Me object.
0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 34934126
Thanks again for you help.

I will do this from now on.
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

688 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