Re: Function scope in a class module

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ken Halter (Ken_Halter_at_Use_Sparingly_Hotmail.com)
Date: 09/14/04


Date: Tue, 14 Sep 2004 12:50:51 -0700

Doug Donaldson wrote:
> Any suggestions?

adding to Tim's reply,

Thing is... you can have several instances of a class. That means you
need to be specific about the instance you're trying to use.

I'm not sure how your dll's put together but it probably starts with a
class that loads the forms. If you're not doing so already, those forms
should be created using object variables instead of writing something
like Form1.Show since there may be several instances of your main class
running as well.... anyway, your form needs a reference to the class you
want to use so you'll need something that looks a little like....

Private Sub Form_Load()
Dim o As Class1
Dim i As Integer

Set o = New Class1
i = o.TheNameOfYourFunction

Note that, if the name of your function doesn't show in intellisense
when you hit the period after the "o" above, there's a problem somewhere.

Also note that you should declare the function as Friend unless you plan
to use it from outside of the DLL. If you declare it Public, you won't
be able to change anything about its interface (name/args/etc) without
breaking Binary Compatibility... if you break, you'll have to rebuild
any apps that use the DLL.

-- 
Ken Halter - MS-MVP-VB - http://www.vbsight.com
Please keep all discussions in the groups..


Relevant Pages

  • Problems with structure in structure and DLL function call in VB.NET
    ... The data structure I need to pass to a DLL function call has a structure ... Dim Cst_DECKS As DbLong ... Private Declare Function ShPlcDb_Rd_Data ...
    (microsoft.public.dotnet.languages.vb)
  • Problems with structure in structure and DLL function call in VB.NET
    ... The data structure I need to pass to a DLL function call has a structure ... Dim Cst_DECKS As DbLong ... Private Declare Function ShPlcDb_Rd_Data ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Anyone know the source of this code?
    ... Calling Visual C++ DLL Functions ... The problem is with your declare. ... you can't return that as a string in VB. ... Dim bStr() As Byte ...
    (microsoft.public.vb.general.discussion)
  • Re: Calling of C# methods from VB.Net
    ... Compile your C# class into a Dll and Add Reference to it ... from your VB project and then, declare a type of the C# class ... Dim o as Class1 ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Unsigned 32 bit
    ... This helper dll has the base adress 0x02400000. ... Its equivalent VB declare is ... Dim MyVar As Long, AdressOfMyVar1 As Long, AdressOfMyVar2 As Long ... Both project internal adresses are inside the jump table VB has build. ...
    (microsoft.public.vb.general.discussion)