Hello,
I have an Addin project. Which has a Connect class.
At some point in Connect.OnConnection() a form is spawned to capture
some user input.
Before the form close, I would like to send that input back to one of
Connect's public strings,
eg, inside the form class's submit button handler,
Connect.str_user_input = txtInput.Text;
However I get a build error for this :
"An object reference is required for the nonstatic field, method, or
property MyAddinProject.Connect.str_user_input"
How do I achieve what I'd like to do? how to work around this error? Is
what I want feasible or not? Thanks a lot in advance.
Data.
Peter Macej - 22 May 2006 09:31 GMT
> "An object reference is required for the nonstatic field, method, or
> property MyAddinProject.Connect.str_user_input"
You are trying to set str_user_input variable via class name Connect and
not particular Connect instance. You can do this only if str_user_input
is defined as static (Shared in VB). So you can:
1. In Connect, define str_user_input with "static" keyword. Not the best
approach.
2. Create public or internal property userInput in your form. Set its
value in the button handler:
this.userInput = txtInput.Text;
Then you can easily read myForm.userInput from Connect class if myForm
is an instance (not class name) of your form.

Signature
Peter Macej
Helixoft - http://www.vbdocman.com
VBdocman - Automatic generator of technical documentation for VB, VB
.NET and ASP .NET code
datamodel - 22 May 2006 12:52 GMT
Thanks a lot for the reply. This is good advice for this issue.
I've also resolved the issue using another method. I defined a an event
handler class, and a delegate for its args, and made the form to send
that event to be handled by Connect.
More complicated - so your solution remains the simpler route.
Thanks