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


ADVERTISEMENT

Unable To Use An Instance Of The Nested Class Through A Public Variable Of The Parent Class?

Jun 7, 2012

I want to created a nested class that can only be visible to and instantiated from the parent class.But I also want to be able to use an instance of the nested class through a public variable of the parent class.I tried making the nested class private, or making the nested class' constructor private, but it won't compile.Is it possible to do this in .NET?

[Code]...

View 3 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

Retrieve A Property Of A Class As A Collection?

May 26, 2012

I'm working on a small project and got into some troubles trying to keep it OOP.I have a global variable:

Public Stations As New Microsoft.VisualBasic.Collection()
And 2 classess: Station & Unit:
Public Class Station

[code].....

View 1 Replies

Retrieve The Attributes Of A Class's Property Specifically

Jan 4, 2011

I am trying to retrieve the Attributes of a class's property specifically. So for example. Let's say I have a class called "Employee", and a custom attribute called CustomLabelAttribute with a string value. What would I need to do to retrieve the value of CustomLabelAttribute for Employee.FirstName specifically? I assume I will need to use reflection, but it's kind of new to me, and I've just recently started using it on any level.

[Code]....

View 3 Replies

Runtime Error 1004 : Unable To Get The Correl Property Of The Worksheetfunction Class

Apr 9, 2012

my error code is run-time error 1004 unable to get the correl property of the worksheetfunction class. I read the data from xlsx-files to one dimensional arrays in my vb - program. the essencial code parts are

Option Explicit
Option Base 1
Dim winvyf() As Double, winvx() As Double

[code]....

View 1 Replies

Dynamically Referencing Class Property With A Variable?

Feb 4, 2009

So Im iterating through the properties of a class. For each property Im iterating through a datatable until I find a column name with the same name as the property.

No worries so far, here's the isse: Once I've found a match I want to set the class's property to the value in the datatable but I'm having difficulty referencing the property as it has to be done through a variable.

Code:
Dim per As New Person
Dim t As Type = per.GetType
For Each p As PropertyInfo In t.GetProperties

[Code].....

View 2 Replies

C# - Using The Value From The Private Variable Or From The Actual Property In Class Functions?

Dec 30, 2009

When referencing class properties from a function within the class do you use the value from the actual property or the private variable value?

public class
private m_Foo as double
public property Foo() as double

[Code].....

View 7 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

Inside The Service Class, Declare A Class Variable Named Started?

May 8, 2012

Create a class named Service. Inside the Service class, declare a class variable named Started. The datatype of this variable is Boolean.Public Class Service Dim started as Boolean End Class Create a class named Server. Inside the Server class, declare a dynamic array that can contain elements of the type Service.(Note: For convenience, both the array and the variable Started can be accessible from a client program that creates an instance of Server and Service respectively)

Create a constructor for the Service class. When the constructor is executed, it will set the value of the class variable Started to True. Create two new classes: WebServer and DatabaseEngine. Both of these classes inherit from the class Service. Inside the Service class, declare a Sub procedure (method) named Terminate. This method should display the following text Service stopping in a message box when executed.This method can be overridden in classes that inherit from Service class.

Inside both the WebServer and DatabaseEngine class, override the method Terminate inherited from their base class Service. Both methods should first call the base class Terminate method. The messages Web server stopping and Database engine stopping should also be displayed in a message box when the Terminate method for the WebServer and DatabaseEngine are called respectively. These messages should only be displayed if the Started variable inherited from their base class is not equal to False.

Inside the Server class, declare a method named Shutdown. This method does not return any value. When executed, it will call the Terminate method for each of the Service instances (if any) in the arrServices
array. You should call the Terminate method within a For Each loop that loops through the elements of the arrServices array.

In the Sub Main method, create an instance of the class Server. Set the size of the arrServices array in
your Server instance to contain 2 elements. Create first a WebServer instance and then a DatabaseEngine
instance into this array. Call the Shutdown method from your Server instance.

View 7 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

Variable Class Names - Rename My Class Human To Man

Dec 18, 2009

What i'm trying to do:

I've got a library which includes a class:

Class Human
End Class
and another class which refers to the human class

Class ASD
Private somevar as new Human
End Class

Ok now i've got a problem, i wish to rename my class Human, to Man. i've got to change Human to Man 2 times, which is OK but the problem is that in the real case, its not just 2 times, its like 500 times or more.

Well its something like a PHP on Javascript.

the following shows the solution of what i'm trying to do, but its in another language PHP/Javascript:

note: in php $ sign declares a variable, echo writes the variable out

CODE:

Is there anyway to do that with VB?

View 6 Replies

.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

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

Defining A Global-class Variable Before The Class Is Used?

Jan 31, 2011

I have the following code:

Option Explicit On
Imports System.DirectoryServices
Imports System.IO

[code].....

View 4 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

WithEvents Variable 'PreviousPage' Conflicts With Property 'PreviousPage' In The Base Class 'Page' And Should Be Declared 'Shadows'?

Feb 1, 2012

I am converting an application from vb.net 2003 to 2005. I got the following warning and need help how to resolve it. withEvents variable 'PreviousPage' conflicts with property 'PreviousPage' in the base class 'Page' and should be declared 'Shadows'

View 1 Replies

C# - Usage Of FieldInfo Class In .NET REFLECTION?

Mar 11, 2011

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As
System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(_Class))

[code]....

How can I reach that sqlparameter collection via fieldinfo or other related classes in >NET Reflection?

View 1 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

VB 10 Class Project/Single Array Usage?

Mar 11, 2012

I'm doing a project for my beginners programming,logic, and design class. The project is a Sales Solution/Bonus Calculator. I really just want to know if I actually coded the array correctly. I've found the same project on here but I wasn't even really sure if what they had up was correct. I have a pretty solid idea of how to get through this I'm just feeling a bit overwhelmed. If you notice any other errors please point them out. I'm not looking for the answer I'm just looking for the path to get there on my own merit. Here's what I have so far:

Public Class Form1
Private Sub Report_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CreateReport.Click

[code]......

View 2 Replies

Size Of The Class Affect The Memory Usage Of The Application?

Jan 27, 2010

Does a the size of the class affect the memory usage of the application? is it better to break big classes into smaller classes or just group them up into one big class.

View 2 Replies

Use TaskManager CPU And Mem Usage Data Along With Process Class GetProcesses Method?

Feb 23, 2010

I am iterating processes using the Process class GetProcesses method. I would like to display information formatted similarly to the way the TaskManager displays it. Where to I get the CPU and Mem Usage data that the TaskManager displays?

View 2 Replies

Unable To Retrieve AplicationSettings Information (object Name, Property Name) For Connection?

Dec 5, 2006

I am faced with the prospect of having to completely rewrite the application.I have suddenly started to get this error message all the time - it seemed to start after I added a table to the schema, but deleting the table makes no difference. I can't see anything wrong with the connection string, but as it seems to be entirely undocumented, that doesn't mean much.

The connection string contains DataSource=.SQLEXPRESS;AttachDbFilename=|DataDirectory| est.mdf;Integrated Security=True;User Instance=Trueand certainly the string works when I use "test connection" from the application setting edit box. I am assuming that for some reason it is not evaluating the Data Directory , but can't see any reason why it shouldn't. Any ideas gratefully received! What might be a clue though is that I can't get rid of the table I added. I have deleted it from the database, deleted it from designer and saved the file, but it just keeps reapearing! Even when it is not showing, there is still a
table adapter in the .xsd file. I am reluctant to start editing this manually because of the danger of screwing something else up - I did try but it caused an error somewhere else (VS helpfully didn't say where)

View 1 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

Unable To Load One Or More Of The Requested Types - Retrieve The LoaderExceptions Property For More Information

Nov 23, 2009

Does anyone know what the problem is with this error message? One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

View 2 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

VS 2005 Store / Retrieve Variable Or Property?

Oct 27, 2009

In the application I'm documenting, sometimes a value is stored in a Public variable & other times it's passed to/from a Public Property which does nothing except store it in/retrieve it from a Private variable. (And in one memorable exception, the Public Property stored it in a Public variable-I'm almost certain that was an oversight by the original programmer though.)

I know that passing it to/from the Public Property has the potential for better validation, but if the Property doesn't actually do anything except store/retrieve it is there any benefit to declaring it as a Property? (Or maybe I should put that the other way around. Personally I'd declare them all as properties because that will allow adding validation later-but I'm not rewriting this, I'm just trying to document it and, in this case, trying to figure out why sometimes it's done as a property & sometimes as a Public variable.)

View 2 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







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