Solved

Save setting code with VB2010

Posted on 2011-02-19
10
1,426 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
Technology Partners: 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 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