Solved

Save setting code with VB2010

Posted on 2011-02-19
10
1,425 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
  • 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
vb6, excel Run-time error 1004 method 'close' of object 'workbooks' failed 7 57
TT Auto Dashboard 13 95
Advice in Xamarin 21 97
How to read File Date Created using VB6 8 52
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

831 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