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


ADVERTISEMENT

Defining A Class For Multiple Child Class Instances?

Feb 10, 2011

I have created a class for a Sports Facility. A facility has a Name, Status, Notes, etc as members of the class. This works well, I can create a new instance of an exisitng Sports Facility from the database, create a new instance, etc. All working well.What I am stuck on is accessing a list of Sports Facilities. I know I can create a new list by doing

Dim List As New List(Of Facility)

For Each fRow As DataRow In ds.Tables("Facilities").Rows

List.Add(New Facility(fRow.Item("FacilityID"))

Next

View 4 Replies

Access Global Variable Inside Class Contained Within Module?

Nov 25, 2009

I've got a console app with a sub main then i have a seperate class inside the module..i can't seem to update the public global variable from inside the class as i can't declare the variable as shared...

View 6 Replies

Defining Something As A Class

Jul 17, 2009

I have .cls files that have attributes for XML files, and i would like to refer to them in the main body of my code without having to define each one as a class in the code as this would be writing them twice. How can i refer to a .cls file in a vb.net form? If you're not living on the edge, you're taking up too much room

View 5 Replies

Defining Controls From A Different Class?

Sep 16, 2009

How do I define the controls from another class? Here is my code (highlighted) -

Imports System.Windows.Forms
Namespace Bryanlgh.Echo.Views
Namespace Bryanlgh.Core.Tasks

[Code]....

I also tried using Imports Bryanlgh.Echo.Views instead of Namespace and it also came up with 3 error messages -

1. Namespace or type specified in the Imports ' Bryanlgh.Echo.Views' doesn�t contain a public member or cannot be found.

2. Name 'cboPcpMd is not declared.

3. Name 'cboPhysicianPerforming' is not declared

How should I define these controls?

View 2 Replies

What Is Attribute And What Is Its Use While Defining Functions,Sub Or Class

Sep 3, 2010

i am comfortable with class, namespace ,Sub ,Function ,Properties ...and so on. i studied about Custom Controls and Extension methods. There i found something new so called Attribute that are placed before classes and Functions definitions.[code...]

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

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

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

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

Side Effects Of Defining A Structure Inside A Class?

Jun 6, 2011

What is the side effects of defining a structure inside a class (name it X), and create a property inside that class of the type X?

View 1 Replies

Call Global / Public Class Anywhere

May 23, 2012

I have Errorlog.vb in my vb.net 2008 project. It is for public class. Public Class ErrorLogger I want to call this public class anywhere. So on EACH vb file I use import "mainproject name".ErrorLogger How can I declare once some where at the beginning and that class will be availabe through out the project?

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

Call New Class With Global Scope From Function?

Dec 4, 2011

I want to create a new instance of a class when I click on a button, but I need to interact with members of that class using other controls on the form, so I need the class to have a global scope. I know I could call the new class in formload, but the class creates certain variables that need to be current. If it is done on formload, the variables wouldn't be current, because if the class is created at formload, it would have different info at that time. Surely, there must be a way to create an instance of the myClass from within a sub that is accessible from other subs of the same class.

[Code]...

View 2 Replies

VS 2010 Global Object For Custom Class?

Feb 24, 2011

This is also posted in the database development forum. As I think the same problem could apply to things other than connections, I am posting it here also. I have created a custom class. All methods in this class, I want to interact with a single connection object.

Imports MySql.Data.MySqlClient
Public Class clsRegTester
Private cn As New MySqlConnection

[code].....

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

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

Class Inheritance Object Variable Or With Block Variable Not Set?

Sep 26, 2011

i had a class called Tag with a structure like:

public class Tag
private _members
public properties
public shared database_methods
end class

this class was tailored for mysql database. i'm currently adding access 2007 support so i split tag into tag and tagdata with structures like:

[Code]...

View 2 Replies

C# - Get The Type For A Class By Sending Just The Name Of The Class Instead Of The Class Itself As The Parameter?

Sep 11, 2009

Dim a as Type=GetType(className) would gimme the type. But I have only the name of the class as string. I want something like GetType("class1") which would return the type.

View 2 Replies

Can't Make Difference Between Public Class And Private Class And Friend And Protected Friend Class

May 15, 2009

I can't make difference between public class and private class and friend and protected friend class.

View 1 Replies

Overload Operator In Generic Class With Generic Interface Of Super Class And Inherit Class?

Jan 21, 2010

I can do this without problem.

Class A
End Class
Class B : Inherit A
End Class
Dim Obj1 As A = New B

View 4 Replies

Use CType To Change An Object Variable "obj" To Custom Class That Reference Using A String Variable Like Obj.GetType.Name?

Feb 9, 2011

The code below works for the class that I hard coded "XCCustomers" in my RetrieveIDandName method where I use CType. However, I would like to be able to pass in various classes and property names to get the integer and string LIST returned. For example, in my code below, I would like to also pass in "XCEmployees" to my RetrieveIDandName method. I feel so close... I was hoping someone knew how to use CType where I can pass in the class name as a string variable.

Note, all the other examples I have seen and tried fail because we are using Option Strict On which disallows late binding. That is why I need to use CType.I also studied the "Activator.CreateInstance" code examples to try to get the class reference instance by string name but I was unable to get CType to work with that.When I use obj.GetType.Name or obj.GetType.FullName in place of the "XCCustomers" in CType(obj, XCCustomers)(i)I get the error "Type 'obj.GetType.Name' is not defined" or "Type 'obj.GetType.FullName' is not defined"

'+++++++++++++++++++++++++++++++
Imports DataLaasXC.Business
Imports DataLaasXC.Utilities

[code]....

View 2 Replies

Get Variable Name Within Class?

Mar 9, 2010

How does a class get the name of the variable that instantiated it?[code]...

View 9 Replies

Get Variable Value From Another Sub In The Same Class

Aug 15, 2011

I have 2 subs in my class. I need to use the values in the variables in the first sub in my second sub. like this.

Public sub test1()

Dim one as double = 12
Dim two as double = 10

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

But I do not remember how to do it.

View 1 Replies

Variable In A Different Class?

Mar 12, 2012

I have form1.vb and class1.vb

Code removed

What I am trying to do is very simple now. Pointx and Pointy in Class1 is underlined. How do I get that variable value (which the form1 finds) into class1.

View 14 Replies

Define Some Global Variables Of A Class - Variables Occupy Memory?

Mar 23, 2012

I define some global variables of a class as follows:

Private Class MyClass
Private var1 as Decimal
Private list1 as List(Of string)[code].....

But I found that after this form is closed, all above variables, var1, list1, list2 still exist in memory. I thought they should be collected by gc since the form is already disposed as I confirmed.

Add: I have monitored half an hour after the form is closed. But these variables are not collected by gc. I have an automatic update procedure on the form which uses above variables.Since the above variables still hold values, the automatic update procedure is always called which causes exception. (One quick fix is to check if form.isDisposed in update procedure. But I do not think this is elegeant. Besides, these variables occupy memory.)

View 2 Replies

.net - Using A Class Like A Public Variable In Asp.net?

Apr 13, 2009

I'm getting an error in .net when trying to declare a Public class on my code behind page.

Partial Class _Default Inherits System.Web.UI.Page

Public someVariable as integer
Public someClass as className

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load [...]

The error I'm getting is BC30508: 'someClass' cannot expose type 'className' in namespace '<Default>' through class '_Default'.The goal here is accessing the class properties in script blocks on the aspx page like this <%=someClass.classProperty%>

I'm not sure if I'm trying the right methods (I've tried several ways of declaring the public class) or if it can even be done..

View 3 Replies

Access A Variable From One Class And Use In Another?

Mar 4, 2012

I want to do this: [URL] but in VB. I believe that is for C# I have 2 classes.

[Code]....

I know I've been asking too many questions lately and I do apologise for that. I am trying to learn the basics

View 12 Replies







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