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


ADVERTISEMENT

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

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

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

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

.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

Access The Variable From Another Class

Dec 1, 2011

how to access the variable from another [Code] I need to call the variable invoiceno in the class xmlserializer using ord1 and assign the value which the user enters during the runtime.

View 6 Replies

Call A Class From A Variable?

Jul 17, 2009

How can I call a class from a variable ?

Something like :

Dim strClassName As string = "clsAction"
Dim newclass = strClassName

I know that this code doesn't work, but how can I do it, if possible.

View 4 Replies

Change Variable In Different Class?

Mar 8, 2012

Looking for the best way to update a variable in a different class. Below is a rough outline of the situation.

I am wondering if in fnSendEmailTo if I can access the Property in CB?[code]...

View 4 Replies

Variable Scope Outside A Class?

Jun 12, 2011

how to declare scope for variables outside their class?

Here's what i have in a class known Create_User:
Public Class Create_User
Public conn As New SqlConnection(My.Settings.HotelConnectionString)
Public usercmd As SqlCommand

[Code]....

How can i increase the scope of these variables to be used in another class? I dont want to keep declaring them again and again.

View 4 Replies

.net Store Reference Of Variable In Another Class?

Dec 25, 2011

Class1:

Dim v as integer
public sub storeVar(byval s as integer)
v = s
end sub

[code].....

I need to save a reference of variable s in Class2 in variable v in Class1.(i.e. when the value of s changes v also changes (and vice versa)Is this possible since vb.net doesn't have pointers?Will it work if I change "byval" to "byref"?

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

Assign To Variable If Inherits From Class .NET 2.0

Mar 31, 2009

I think I remember reading somewhere that it was possible to assign items to a variable if the item inherited from a base class, but I can't remember how.

I want to have a class that gets properties set and one of the properties is an error code property. I want to assign any exceptions that occur to the property, but it could be any type of exception. I remember that all exceptions inherit from the Exception class.

How can I assign an exception to a property based on the class it inherits from?

View 4 Replies

Assigning A Variable To A Class Then Storing?

Sep 30, 2009

i'm working on a code that i want to start creating new classes with but i want to know if there's a more direct way to send the variables used in the form to a new class for storage.

for example i've got this on a form...

Dim ClassID As String
Dim ClassName As String
Dim Grade As String

[Code]....

you know? so what would be my most direct route to get this? how should i start?

View 15 Replies

Declared A Class Variable Inside Sub?

Jul 26, 2010

I have a text file to read, at the first line will have a size of array, that means I cannot guess size of array, and I have to create a array in side a sub (Local Variable). Then, I want to use value of array in another sub, but I cannot use value of variable of another sub. What I have to do to make an array con be used in every sub/function in a class? Also, I've post an example file, code and error list.

[Code]...

View 1 Replies

Declaring Class Variable As A Reference?

Apr 5, 2011

I have a class that I would like to link at construction to a given control (say a textbox)

I know I can put a variable into a subroutine referentially but is there a way to store it in the same capacity?

View 1 Replies

Dim A Variable That Will Be Used Make A Class And Then Ferer To It?

Jun 10, 2010

Having trouble accessing a dim variable inside a btOk or Load event. when I dim a variable that will be used a lot, do I need to make it a class and then referer to it?

View 7 Replies

Don't Want Any Access To Superclasses Class Variable

Sep 10, 2009

i have an abstract super class and a sublcass.I don't want any access to the superclasses class variable.Access should only be through the subclass method [code] ' now i just want the GetFoo method exposed however all i get is ' direct access to the Foo string.' I made it Friend so that only the derived class SubClass can see it ' but my main program can see it as well//How can i set this up so that the only call availabe would be
x.GetFoo()What have i got wrong ?

View 6 Replies

Forms :: Pass A Variable From Within A Class

Jun 25, 2011

i have a class called car and within that class i have a few vairables

Public Class car
Public Property Name As String
Public Property ID As Byte

[Code].....

View 5 Replies

Get A Class Properties Underlining Variable?

Jan 5, 2010

Is it possible to get a Class properties underlining variable.because GeValue / SetValue need and object to work with.

View 4 Replies

Give Value To Variable In Class Library?

May 22, 2010

i have a ClassLibrary and i set some Private Variable like: Private _Test as string and i have to get the value frome Database and set it to my valiable and after that i want to set some function that return it like:

Public Function GetTest() as String
return _Test
end Function

how can i set a value to _Test befor return it?

View 2 Replies

Hide Variable From The Rest Of The Class?

May 22, 2009

Public Class frmMain
Private p_dlgAdd As frmAdd = Nothing
Public ReadOnly Property _dlgAdd As frmAdd

[code].....

View 4 Replies

How To Access Class Variable Via Array

Mar 23, 2009

If I have the following class and declaration:

Public Class objLocation
Public SysLocationId As String
Public NameFull As String
Public LatRaw As String
Public LongRaw As String
Public Active As Integer
End Class
dim lLocation as new objLocation

I can access each variable thus lLocation.SysLocationId, etc. Is there an alternate way, so I can access each variable by index, so something like lLocation(0), lLocation(1), etc., which gives me the flexibility to compare to classes of the same type via a for next loop, or against other sources, like a datatable.

View 6 Replies







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