com >> Accessing DLL class Variables and values

by Dixon » Tue, 10 Jan 2006 21:42:09 GMT

I have a DLL file where i hav a type like the one below.......

public type Items
ItemName() as string
Count as integer
end type

and i have a variable declared for this type

public t as Items

I create an object for this DLL in my client application,

dim obj as new DLLClassName

now with this object when i need to put some value into the string
array how do i do that

i tried with this

obj.t.ItemName(0)="Item0"
msgbox obj.t.Count

This doesnt seem to be working

Should i use the get and let procedures to use this



com >> Accessing DLL class Variables and values

by Norm Cook » Tue, 10 Jan 2006 22:38:51 GMT


Here's a very bare bones string array class. There more
efficient ways of doing this--namely a collection class.

'class Items
Option Explicit
Private ItemName() As String
Public Count As Long

Public Sub Add(ByVal Item As String)
'check validity of the string here
Count = Count + 1
ReDim Preserve ItemName(1 To Count)
ItemName(Count) = Item
End Sub
Public Function GetItem(ByVal Index As Long)
If Index > 0 And Index <= Count Then
GetItem = ItemName(Index)
End If
End Function

'form code
Option Explicit
Private Sub Form_Load()
Dim oItems As Items
Dim i As Long
Set oItems = New Items
oItems.Add "hello"
oItems.Add "world"
Debug.Print oItems.Count
For i = 1 To oItems.Count
Debug.Print oItems.GetItem(i)
Next
End Sub









com >> Accessing DLL class Variables and values

by Dixon » Wed, 11 Jan 2006 15:25:25 GMT

Excellent Thank U soo much It worked



Similar Threads

1. Pass variable value into class and use as public within class

Hi there,

Having done much web development in recent times im a bit new to vb.net
and uses of classes.

Basically in my VB.Net code i call a connection to unidata then  using
this connection i set a variable value e.g. val_A.

I then instantiate a class

within the class i need access to my val_A which i have set in a
seperate class.

how do i do this ???

any help appreciated

CG

2. Nested class: accessing containing class's variables - VB.Net

3. Accessing class member variables - properties or variables?

Only expose your private members if you wish them to be publicly acessible, 
that sounded horrible... I only create properties to be externally consumed 
by another class, say I have a class that gets loaded from the database and I 
have a property that accesses the data:

    Public Overridable ReadOnly Property SomeData() As String
        Get
            Return m_SomeData
        End Get
    End Property

I'm going to poulate this properties value using the private member 
m_SomeData, that way I don't interfere with anyone else's implementation 
should they descide to override this property.

"dwok" wrote:

>  I have been wondering this for a while now. Suppose I have a class
> that contains some private member variables. How should I access the
> variables throughout the class? Should I use properties that expose the
> variables or is it OK to just access the variables directly? Keep in
> mind that I am talking about accessing the variables from within the
> class that they are defined. Thanks!
> 
> 

4. Excel value/variables to Word value/variable? - Word VBA

5. cant assign variable values to property in Class file

Hi

      I am creating web application in which i want to assign by
default values to the property which i had created my own. In that one
of the property is of type color and i am unable to assign any value to
that color type property..

     my code is

     Dim Col1Color as String

     vartable="------"
     vartable&= TDCOLOR1

    i got error:- & operator not defined for System.Object and
syste.Drawing.Color

    plz help me out

    Thanks in advance

6. Get class property value where name in variable - VB.Net

7. Accessing variables in referenced class library

Hi,

I have created a class library creating a number of forms and a few public
variables.  I have a project that references the .dll for this class
library, and in that project I need to access those public variables.

For instance, the main app calls a form in the referenced library, that form
changes the value of PublicVar1 and then closes.  The main app now needs to
know the value of PublicVar1.

How can I do this?

Thanks,
Nathan



8. How does child class access parent's variables - VB.Net