• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1433
  • Last Modified:

Save setting code with VB2010

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
Wilder1626
Asked:
Wilder1626
  • 5
  • 3
  • 2
1 Solution
 
jimswebCommented:
0
 
Wilder1626Author Commented:
I see that this is for VB Net

Is this the same for Visual Basic classic?
0
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.

 
GrahamSkanCommented:
Try specifying the text property of the text box.

SaveSetting("MyApp", "Settings", "TexttxtBaseDelabsolution", Form2.txtBaseDelabsolution.Text)
0
 
Wilder1626Author Commented:
Hello GrahamSkan

No sorry, even with the .Text, still the same issue.
0
 
Wilder1626Author Commented:
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
 
Wilder1626Author Commented:
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
 
GrahamSkanCommented:
I have tested that with VB2010 and it works for me. Are you sure that Form2.txtBaseDelabsolution exists?
0
 
GrahamSkanCommented:
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
 
Wilder1626Author Commented:
Thanks again for you help.

I will do this from now on.
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.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now