.net - Accessing Property Of A Class Without Inherting The Class

Apr 7, 2012

I have a class that has the following property that is generated by the methods in the constructor.

Public Class clsLoadTables
Private _ds As New DataSet
Public Property ds() As DataSet
Get

[CODE]........................

My problem is that I do not want to inherit this class, but I have other classes that need to access the ds DataSet property. If at all possible I would like to not use inheritance and not load my datatable more than once in the program.

Here is my failed attempt to access the property inside another class that is not inheriting clsLoadTables:

[CODE].........................

How I can access this dataset that I want to load only once in the program from many classes without using class inheritance or a global module?

View 3 Replies


ADVERTISEMENT

Database Accessing An Initiated Class From Another Class?

Oct 9, 2011

I have the following defined in my "Form1":So that I can access all my database functions anywhere in the main form (database connection is initialized via the "private sub new()" function in the DatabaseManager class.The works fine for all queries done in form1, however I have many other classes I'd like to be able to access the database from.Does anyone know how to access the initiated class in my example? Since right now it is initiated in the main form, if I try to access any functions inside any ot

View 4 Replies

.net - Suppress A Property Or Method From A Base-class In A Derived Class?

Apr 7, 2011

Supose a base class

Public Class airplane
Private var_num_seats As Integer
Private var_num_engines As Integer

[code]....

Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?

View 2 Replies

Can't Set DataTable Class Level Variable = Class Table Property?

Sep 29, 2011

I have procedure (Import) that calls a for a new instance of frmImportData. I also have a class name clsBatch that has a data table property called prpParametersTable.For some reason, I get an error (indicated below with ERROR>>>) when trying to assign prpParameterTable to cv_dtImport2. The error states "Object reference not set to an instance of an object.". Why does this error not happen when I assign dtBP to cv_dtImport1? Both cv_dtImport1 and cv_dtImport2 are equal to Nothing and in my Import procedure dtBP = prpParametersTable.

Public Sub Import(ByVal clsB As clsBatch)
Try
Me.cv_clsB = clsB

[code]....

View 5 Replies

Class Property Usage - Unable To Retrieve A Variable From On Class

Nov 14, 2009

I have three class files, accounts.vb and transactions.vb in addition to my form.vb. I am unable to retrieve a member variable from on class from inside the other. When the combobox index changes, the program loads the correct account (checking or saving) from two different sequential files. I don't think I have the calcBalance procedure in the correct class file. And that is what I am having trouble with. Accessing it to display it. [Code]

View 1 Replies

Access Members Of A Sub Class Through A Property Of The Parent Class?

Mar 30, 2010

This is a bit of a continuation from a previous post for which AtmaWeapon was very informative.

Problem:
A parent class has a sub class with various properties. A property of the parent class is a List(of T) with T = the sub class The issue is how to store data in the sub class of the instantiated parent

Some example code (hopefully formatted correctly):

Code:
'=========== Class Definitions =============
Public Class courseClass
Public Class timeTableClass

[Code].....

View 7 Replies

Adding A List (of Class) Or Collection As Another Class's Property

Apr 2, 2010

I'm looking for a tutorial on how to Adding a list(of Class) or Collection as another Class's Property.What I am after is something like the Columns Collection for the DatagridView control.I would like to add Items in the graphics screen. Where the item list is displayed in the left panel and the selected Item properties are displayed in the right panel.

View 4 Replies

VS 2005 Class Contain Another Class Within It - Interface And Property?

Jul 29, 2010

I know that an interface can contain another interface within it.But;can a class contain another class within it?Can an interface contain another interface within it?

View 9 Replies

Class Array As Another Class Property?

Jul 28, 2010

I have two classes, and for a property in one of the classes I'd like to be able to load it up with an array of the other class. However my attempt at accomplishing this results in a "Object reference not set to an instance of an object" error. I know it's a rookie mistake, but I'm stumpedssist?

My code is as follows:
Namespace Parking
Public Class garage

[code]......

View 2 Replies

"upgrade" An Object To An Inherited Class, And Keep All The Base Class's Property Values?

Jul 5, 2010

bare with me during this silly example. :-) Let's say I have a class like this:

Public Class Animal
Public iLegs as int32 ' Number of legs
Public bWings as Boolean ' Wings? Yes/No
End Class

And another class that inherits the "Animal" class and adds one more property:

Public Class ScaryAnimal
Inherits Animal
Public iScariness as int32 ' 0-100, how scary is it?
End Class

Now, if I have an instance of "Animal" with some values in it, and I decide I want to cast it to a ScaryAnimal for some reason, how do I do that without having to create a new instance of "ScaryAnimal" and copy each property value?Basically I'm looking for a way to do this, without having to write the lines marked with '*** below:

[Code]...

View 2 Replies

Class C Inherits Class D Is Class D A Superclass Or Parent Of Class C?

Dec 16, 2009

If Class X is within the scope of Class Y, is X a subclass of Y?If Class A is a sub Class of B, then is Class B considered a super class of A?if Class C inherits Class D is Class D a superclass or parent of Class C?if Class E extends Class F then we can consider Class E a child of F?if Class G inherits Class H and is within the scope of Class I then who is the parent of Class G? Classes that inherits Class J and classes that are within Class J are all sub classes of Class J?

View 1 Replies

Form Inheritance - Error1Base Class 'MenuStrip' Specified For Class 'Lesson2' Cannot Be Different From The Base Class

Apr 15, 2010

I have put this code in the global form Inherits System.Windows.Forms.Form. And then in the form that will inherit this from the global Inherits MenuStrip. "MenuStrip" is what the global form is called. But keep getting this error: Error1Base class 'MenuStrip' specified for class 'Lesson2' cannot be different from the base class 'System.Windows.Forms.Form' of one of its other partial types.

View 5 Replies

Accessing Certain Functions In Class

May 9, 2010

I am currently trying to write classes so that I can access certain functions from any form within my VB project.

My class is defined thus:-
Public Class testclass
Public Function showmes()
MsgBox("Hello everyone"")
Return 0
End Function
End Class

I have added the class into my form using this at the top in the form:
Imports WindowsApplication1.testclass
Obviously, WindowsApplication1 being the name of my project, testclass being within a VB file, saved with my project.

I have attempted to call the function from the form using this:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
showmes()
End Sub

However I am getting the error "Reference to a non-shared member requires an object reference." I don't understand why there is a problem, since I have used imports to reference the class.

View 6 Replies

Register The Class File - Not Recognizing My Class.Even The Intellisense Is Not Picking Up Te Class

Jul 22, 2011

I have a class (see below)

Imports Microsoft.VisualBasic
Imports System.Data.SqlClient

Public Class ClientProfile

#Region "Variables"

[CODE]...

It is in the file ClientProfile I have placed in both App_Code and also App_Code/Models

In my code behind I have the following

[CODE]...

The last word, "ClientProfile" has the scary squiggly red line below it. It is not recognizing my class.Even the Intellisense is not picking up te class. Do I have to register the class file in any way?

View 4 Replies

.net - Make A Class Property Behave Like The Checked Property On RadioButton?

Jun 1, 2012

I have a very simple class that holds a few public properties - ID, Text, Colour, etc. and a Boolean called 'SelectedItem'. Just like the Checked property on RadioButtons, only one item can have its SelectedItem property set to True within a particular group. Note: there will be several separate groups (lists), each allowed to have only one item with SelectedItem = True.

My first thought was that I would probably just have to handle everything outside of the class, setting SelectedItem to False for every other item in a particular list when another item was selected. But that seems rather inelegant to me. So I've been trying to think of how this might be done within the class. For example: could I perhaps have a private string property called say "GroupName" - set in the New sub when adding a new instance of the class - and then use a private shared method to set every item's SelectedItem property to False, provided the item has the same GroupName as the newly selected item? I would have a go at doing this but I have no idea how to enumerate every instance of a class from within that class, or whether that's even possible. Is it? Or is there another (better) way to achieve my goal? Here is a cut-down version of what I've got so far:

Public Class ResourceItem
Public ID As Integer
Public Text As String[code]....

As can be seen: instead of instantiating a new ResourceItem and passing that as an argument to the manager's Add procedure, I'm simply passing the details of the new item and the procedure is creating the item from those. I don't know whether this is a good or bad idea - please advise - but I've done it because I couldn't figure out how to make the SelectedItem property only writeable by the manager, so I wanted to avoid having directly accessible objects that could have their SelectedItem property set to True without it deselecting all the other items in the same group. Of course that still leaves the possibility of setting a variable to one of the manager's list items and setting it from there, so I would still like to know how I could prevent that, if possible.

UPDATE: I didn't use the code above in the end, deciding instead to go with Cyborgx37's solution - which seems to work perfectly well for me despite the warnings about best practice. I also realised I would need to use the same class in another scenario where multiple items could be selected, so it was easy to add a Boolean property to the manager to enable that.

View 2 Replies

.net - Accessing Class Properties In Xaml?

Feb 18, 2010

I've currently created the class below. For some reason though I can't access the properties I've created through my xaml style.

Public Class Ribbon : Inherits Button
Private mpopDropdown As Popup
Public Property Dropdown() As Popup

[Code].....

but they don't seem to expose the property either. I've also tagged the property as <Bindable(True)> but that didn't seem to do anything.

View 2 Replies

Accessing And Using Array In Class Module

Mar 1, 2010

Any some simple examples of how arrays can be put in a Class Module? The examples should show how the array is used and accessed in a form.

View 3 Replies

Accessing Arrays In A Class Via Properties?

Apr 8, 2010

Is it possible for one class to access an array of values within another class as a readonly property of the second class? All of the examples and references on class properties imply that one can only retrieve one value by calling a class' property.

View 2 Replies

Accessing Instance Of A Class Through A Variable?

Nov 12, 2010

i have

VariableA as Class1
Variable1 as string
Variable1 = "VariableA"

I want to be able to use Variable1 to get access to VariableA(?).

So i want to able to do something like

VariableA.Property1 = "test"
But like this:
Variable1.Property1 = "test"

View 5 Replies

Accessing Textbox Input In A Class?

Feb 20, 2012

I am new to VB and am having a little trouble with my class assignment. Basically it is supposed to take an invoice subtotal - find the discount percent and give the real total. I cant seem to get my class to access the textbox for user input and it just keeps returning 0's. This is a homework assignment as well... im not asking for the answer just some tips because i am truly at a loss and cannot figure this out

This is my code from the button click event:

[Code]...

View 1 Replies

Accessing Two Dimensional Arrays Within A Class?

Aug 30, 2011

Ive currently got this:

Public Class World
Dim StringA() As String
Property SetString() As String()
Get

[code]....

I need StringA to be a Two-Dimensional Array. I've played around with it and was unable to figure it out..

View 6 Replies

Communications :: Accessing A Class Function?

Oct 28, 2008

I am working on this project and this question seems to be stupid, but I am not really getting the point.I have the following class:

Code:
Public Class ConnectedServer
Public MYPORT As String = "8000"

[code].....

View 13 Replies

.net - Accessing A Public Class From Global.asax?

Aug 5, 2011

I would love to implement the asp.net routing but i have a basic question.

In my Generic handler i have the following Global class

Public Class MyHandlerRouteHandler : Implements IRouteHandler
Public Function GetHttpHandler(requestContext As System.Web.Routing.RequestContext) As System.Web.IHttpHandler Implements

[Code].....

View 1 Replies

.net - Accessing A TextBox Control From Another Class/thread?

Apr 16, 2011

im trying to access a richtextbox from another class and thread then the ui and i cant seem to get it working. I currently have the sub thats handling the the work inside of a public class and its a sharedsub, im going to be calling it from several different classes and threads but again i cant seem to get it working. the code looks like this. Public Class SharedSubs

[code]...

i would be calling sub using SharedSubs.Console("stringstring") when this is called from the ui thread it works fine but when its called from anyother thread or class its does nothing,ive confirmed it going thru this code but its not displaying anything in the textbox and its not thru an exception due to delegates either which i figured it would.

View 2 Replies

Accessing A Class Persisted On A Hard Disk

May 30, 2009

once a class has been persisted on an hard disk with a strem is it neccessary to load the full class to deal with one part of it or is it possible to get just the part of the class i am interested in?

View 2 Replies

Accessing A Public Shared Variable From A Different Class?

Jan 10, 2012

I currently have two forms, and I need to share the value of a variable in one of them.

I declared the variable to be 'Public Shared', and assigned a value to it. However,

when I inspect the value it appears as 'Nothing'. Here is the snippet:

Public Class A
Public Shared sVar As String = Nothing
Private Sub A_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

[Code]....

View 4 Replies

Accessing Class Obect From Another Form Within A Project?

Jul 22, 2009

I have created a project, and with form3, created a class for datagridview called MyDtGrd.nd when I created a form4 I used that same MyDtGrd. When I used before to publish the program no problem.But after publishing When I tried to make changes, giving error like"The variable MyDtGrd is either undeclared or was never assigned"Is there any technique to access the same class oject to use in other forms?

View 1 Replies

Accessing Public Class Variables In Asp.net Without Session?

Feb 15, 2012

I am using this example I found to learn how to load class files and access variables through them. This is in a file called Class1.vb in the App_Code folder (this is not an app project):

Imports Microsoft.VisualBasic
Public Class my_class
Public Shared Sub my_sub()

[Code]....

How could I access the vartest variable without using a session, since if this is accessed by multiple functions at the same time the variable can be overwritten I assume. Is it possible to go the other way, where a variable is sent to a class file?

View 4 Replies

Accessing Variables In Partial Public Class?

Apr 10, 2009

I am currently working on a project of "interpreting" C# into VB. The project involves adding images to a database, retrieving images from the database and presenting them in thumbnails. Right now I have the following Public Class with the Variable that needs to be assigned:

VB:
Imports System.Data
Imports System.Drawing
Imports System.IO

[code]....

View 6 Replies

C# Accessing Properties Of An Object From A Collection Class?

Jun 10, 2009

I am moving from VB to C#. I am trying to loop through a collection class which is a collection of data classes but I can't seem to get the actual values out of the data class properties(find the correct code to do so). I have a method that loops through the collection class(Contacts) and saves each record(Contact). I am using reflection because my method will not know if it is Contacts class or a Customer class and so forth. Here is my code in VB(watered down)

Public Function SaveCollection(ByVal objCollection as Object, ByVal TableName as string, ByVal spSave as string)
Dim objClass as Object

[Code]....

The C# code keeps returning null. In my locals window I can see the proprties on the class on objClass and the value of the propery but I can seem to figure out how to access it through code. I used the DictionaryBase because that seems to closely match would I need to do. My data class(Contact) has a bunch or properties that match the field names in the database of the Contact Table. After I get the propInfo variable set I then set up my SQLParameter with the fieldname, datatype etc and then set the value to the propInfo.value.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved