[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Reference to a non-shared member requires an object reference

Posted on 2007-10-13
4
Medium Priority
?
745 Views
Last Modified: 2012-05-05
Good Evening

Experts:

I have a bit of a problem here.  Working with VB.net as an AddOn in SAP Business One.  
The problem is related to the .Net so no worries about needing SAP knowledge. I have a Class that calls another Class if the User executes a button click on the calling form.  When leaving the called form I want to refresh the calling form but I am getting an error which I really don't understand.  To refresh I have a subroutine in the calling form called FillBOMTab.  
Public Class ItemTypeMaint
        Public Sub FillBOMTab(ByVal ItNum As String)
        .....
         Dim ItemTypeROUTINGForm As New LBSI_ItemTypeROUTING(ItemNum, SelectedRoutingRowCode, Mode)
         .....
End Class

From the called form I attempt to reference FillBOMTab be qualifying it with the Project and called form reference --> Enhance.ItemTypeMaint.FillBOMTab(RoutingItemNumPassed). However, I am getting the following error:

Reference to a non-shared member requires an object reference.  How do I do that?

Not sure if this is enough info to explain my problem.  So, feel free to ask questions.

Thanks for the help,
jimbo99999
0
Comment
Question by:Jimbo99999
  • 2
4 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 2000 total points
ID: 20073625
In order to use the class that you have created, you must create an INSTANCE of that class, and then you can call the sub using that instance.

If you what to use the class as you have described, then you should change the definition of the class like this:

Public Class ItemTypeMaint
        Shared Sub FillBOMTab(ByVal ItNum As String)
        .....
         Dim ItemTypeROUTINGForm As New LBSI_ItemTypeROUTING(ItemNum, SelectedRoutingRowCode, Mode)
         .....
End Class

This creates the Sub as SHARED - meaning that it is a method of the class, not of an instance of the class.  

You then access this Sub procedure like this:

     ItemTypeMaint.FillBOMTab(RoutingItemNumPassed)


AW
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 20074210
"I have a Class that calls another Class if the User executes a button click on the calling form.  When leaving the called form I want to refresh the calling form but I am getting an error..."

The easiest way to do this is to show the "called" form MODALLY using ShowDialog() instead of Show().  This prevents the user from using the "caller" until the "callee" is closed.  The code in the "callee" is HALTED until the "called" form is closed:

Public Class ItemTypeMaint

        Public Sub Button1_Click(...) Handles Button1.Click
            Dim frm As New YourCalledFormHere
            ' initialize "frm" somehow...

            frm.ShowDialog() '  <-- code STOPS here in "ItemTypeMaint" until "frm" is closed
           
            ' now refresh this form by calling FillBOMTab()...I assume you need to pass it some value from "frm"?
            FillBOMTab(frm.SomeRetrievedValue)
        End Sub

End Class
0
 

Author Comment

by:Jimbo99999
ID: 20199972
Arthur Wood:
Thanks for the help.  It is working now.  I apologize for the tardiness in awarding points...

Have a good day,
jimbo99999
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 20204468
Gald to be of assistance.

AW
0

Featured Post

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!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

834 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