Class - Using Variables For Referencing Objects?

Feb 25, 2010

when using variables in object names.I have a Public class which is called "Tank".In that class, there is a public property called "direction" of an integer type.I keep getting the error:

"Tank is a type and cannot be used as an expression"What I'm doing wrong here ?

Public Class mainroutines()
Create Instances of tank
Private Tank1 As New Tank()[code]....

View 3 Replies


ADVERTISEMENT

Array Of Self-Referencing Objects In A Class

Aug 23, 2010

How can I implement a tree structure (Octree) in Visual Basic.

that is to declare a class containing array of objects of same class type - like

Class Node
{
dim ....

[Code].....

View 3 Replies

Array Of Objects Also Saving Variables Of Class?

Dec 21, 2011

I have a small class of Object CellValue

Friend Class CellValue
Public CellColor As Color = Color.White
Public CellShape As Shape = Shape.Blank
Public CellName As String = ""
End Class

Then in my main I make an array of CellValue but I want to know if the values are also being passed down with the array.

Dim Plan(SizeW - 1, SizeH - 1) As CellValue
Dim CellW As Integer = PictureBox1.Width \ SizeW
Dim CellH As Integer = PictureBox1.Height \ SizeH

[Code].....

Are CellName, CellShape and CellColor being tied to each element in the array?. The reason is because I need to use these properties to tie certain functions to them. The CellName should have a MachineID which I would have to use to pull some info from a Database.

The Array should also be serialized and deserialized to XML as customer needs to create/edit and delete certain values in the array. And in order to save the array has to be in XML

So the Questions are does it save the CellName, CellShape and CellColor for each element, will it be affected if I serialize and deserialize using XML. If possible, how can I call up the Cellname p.e for a specific array element.

View 5 Replies

VS2008/VB: Moving Subclass VB Code To Inherited Base Class - Where Should Variables/objects Be Declared

Jun 3, 2009

In re-engineering a windows forms application, I find that a lot of code-behind in the various form classes is duplicative and I'm trying to centralize as many procedures as possible into a base class which can be inherited and used by the subclassed forms.

This process seems to be going well and is making the code in my subclasses much simpler and hopefully easier to maintain, but I'm not sure where to draw the line between leaving code in the subclasses and engineering for generic resusability and moving it to the base class.

Specifically, in some subclasses I have code which manipulates variables and objects specific to the subclass, and although I could move the code-behind into the base class, the base class code references specific objects which are needed to compile. For example, each subclass manipulates a databound datagridview and form detail controls which allows the user to select between multi-record and detailed single-record views of a datatable.

In Visual Basic 2008 do I need to declare dummy data objects in the base class so that the base class will compile? Or is there a way to indicate that the data objects will be provided by the subclass?

View 13 Replies

Referencing The Dynamic Objects?

Mar 14, 2009

I made a browser and its awesome but i want to reference the browser name so that i can add script to it, I am calling the new browser window "wb" cause that's what it gets named in the script. here is my code. (it labels the tab, the window, and changes the URL text field)

Private Sub wb_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles wb.Navigated
TextBox1.Text = wb.Url.ToString()
Me.Text = CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).DocumentTitle & " - My Browser"

[code]....

It says "Browse.Name = "wb"" so thats why im trying to call it "wb". I inserted a WebBrowser on the form named wb and then tried to run it and it worked, it labeled the window, tab, and changed the URL field. So i know that the script works. Please help me, I know you guys can solve this, I'm really new at this.So my final question is... What should I call the browser instead of "wb" when I am referring to it in the first script I posted above? I am so confused. How do you refer to an object that gets created dynamically?

View 3 Replies

Referencing The Report Objects?

Jan 11, 2012

I'm just trying to reference report objects (specifically textboxes).For example, let's say from a form, the person has to enter a specific title each time the report is run; or they have to enter something that has to appear along side each record in the detail (List) of the report each time it's run.

How to you pull the info on a form into a report? Is this even possible in VB? (it was quite easy in Access)I've tried in the Form code something like: My.Forms.Form3.ReportViewer1.textbox1.text = My.Forms.Form2.TextBox2.TextBut of course it says "textbox1 is not a member of Microsoft.Reporting.WinForms.ReportViewer" Then I've tried adding an Expression to a textbox in the report itself in an attempt to try and pull the data from a form. The Expression for a Report textbox went something like =My.Forms.Form2.TextBox2.Text

View 2 Replies

Dynamically Creating And Referencing Objects?

Mar 17, 2009

I would like to dynamically create an object (in my case a thread) and then be able reference that object. Simplistically put, I would like to read from a text file and then process each item using a thread (so that I don't have to wait for each item before starting the next). The problem is that I cannot think of a way to create a new thread dynamically ie. thread name so that I can then wait for all created threads before doing something else.

View 8 Replies

Storing And Referencing Info In Objects?

Dec 15, 2008

writing a program which stores and uses information on oil pipelines. I have a number of worldwide sites, which each have a number of pipelines. Each pipeline has a number of segments, and each segment has a number of properties like flow rate, temperature, pressure etc. There are also going to be a number of cases, so the temperature of a segment in case 1 might be different to case 2.

What is the best way to set this up in terms of objects and references? I�ve done a fair bit or reading about arrays, collections, classes and think there are a number of ways to �skin this cat�For example, if I wanted to reference the temperature in case 1, of segment 3, in pipeline 4, at worldwide site number 3, then can I do something with a load of objects and collections like the following?

site(3).pipeline(4).segment(3).case(1).temperature.value

Is it possible to have an object heirarchy, where an object has a parent object, and both objects have their own attributes and fields?

View 5 Replies

Referencing Dynamic Objects To Create Events?

Nov 20, 2010

I have a tools strip menu item with dropdown items that are created dynamically.

For Each file In files
Dim newMenu As New ToolStripMenuItem(FileNameOnly(file))
tsmMachType.DropDownItems.Add(newMenu)
Next

So how would I go about setting up or creating events for these items? I need to have a check event and click event for each of the items.

View 10 Replies

Game Programming :: Referencing Dynamically Created Objects?

Apr 26, 2011

I dynamically (by programming text, not drawing in GUI) created a matrix of 10x10 buttons named 'Button1' till 'Button100'. In a formula I calculate a number, say '87'. If I next want to reference 'Button87' and change e.g. the background clolor and text properties, how would I do that? I am creating a PocketPC game using VB2005.

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

Use Variables Or Properties, And Global Or Static Variables In A Class?

Jun 9, 2012

I'm new in .NET programming.I have a class Form1 that includes Button1_Click event.Button1_Click creates a multiple Text Boxies at run time)Here is the class:

Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer

[code].....

View 3 Replies

Creating A Class And Referencing It

Feb 20, 2009

how to create a class yet, and I think I need to learn how.I am wanting to shorten my code in a form, thinking of creating several classes to do so.Lets use a Listview as a reference if you dont mind.Say there is a listview, you have a numeral amount of if statments to fill by. Is there a way to create a class(is this the way to go) so that you can open the class to modify that specific block of code? Example of questionYou have multiple items you need to add for each if statement. Animal as a group Dog as an item 14 years as a sub item Cat as an item 11 years as a sub itemIs this the way to go, if so how do you create a class and call it from a form?Davids Learning

View 4 Replies

Referencing A Class As A Web Service

Nov 18, 2011

I am building application that will be hosted as a web service. This app takes an employeeID and returns an employee object that contains lots of info regarding the employee. (name, status, full-time/part-time, etc)I want the two existing apps we have (and more to come) to be able to call a method that the web service will have and return the employee object. (also at time this web service that returns the object may have new fields added to it - Pay rate, etc)How would I go about creating a new object from this web service reference in the existing applications.Would I decalre it like Dim Employee as new emp_webservice.employee? And then be able to use this object within the app? Or would the better practice be to also included the same class files? It seems like this would not be the way to go, since if I make a change to that class I then have to make it in all places.

View 1 Replies

Referencing Another Variable In Form Class

Dec 24, 2011

How do you reference a variable in another Class?
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TextBox1.Text = "Class1_Text" ' Would like to replace w/correct code
End Sub
End Class
Public Class Class1
Public Class1_Text As String = "Class1 Text"
End Class
I can reference the Form1 data in Class1 but not vice-verse.

View 8 Replies

SNMP Class - Error In Referencing

Jun 4, 2011

I have created an SNMP class. And then I want to test this class, so I create a program which imports this class ...
Imports SNMPClass
Module Module1
End Module
Public Class SimpleSNMP
Public Sub Main(ByVal argv As String())
[Code] .....

I got an error in this line
Dim conn As New SNMP()
Which says "SNMPClass.SNMP is not accessible in this context because it is friend"..
I am using Visual Studio 2008

View 1 Replies

Asp.net - Referencing Class Library In Inline Vb Code

Feb 15, 2012

I'm working on a legacy vb.net application that does most of its work using inline code ( Within that script I need to access functions from a third party .net dll. The dll(s) themself are stored in the GAC. Before I started the page looked something like the following

[Code]...

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

Referencing An Object (class) Within A Thread Fails

Jun 8, 2012

Referencing an object (class) within a thread fails

I have an object ("a vb class") that needs to run on a separate thread and communicate with the U/I.

Even using sample code, I cannot get the object to run within a thread. I demonstrate this problem with two examples. The first calls a function within the form and it works perfectly. The second creates an object and performs the same calls, but fails.

example #1 [working] (Called within a form)
Private Delegate Sub FuctionToBeRunInThreadDelegate
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

[Code]....

SUMMARY: When the thread creates the object, it appears that the object is not actually running inside of a thread or else form.InvokeRequired would be true. I have other more complex examples where this is strongly verified and evidenced, but I provided these two as a very simple demonstration of my problem.How can I have a thread "own" a series of individual objects so that the objects are run asynchronously and can independently report back to the U/I?

View 1 Replies

Class Referencing - Form4.vb Doesnt See The Shared Class1

Aug 12, 2011

I have class file class1.vb with 3 classes class1 , class2, class3. a class file class10.vb with class10 class11 class13

I declared class 1 public and declared a public shared new instance of class11 in class1 at the top

All classes in class1.vb can use this shared instance, but a form4.vb doesnt see the shared class1.(new instance of class11)

View 1 Replies

VS 2008 Referencing A Property In The Parent ITEMS Class

May 6, 2010

I have a collection class, say ITEMS, that inherits a Dictionary (of String, SINGLEITEM). From the SINGLEITEM class, I would like to reference a property in the parent ITEMS class, what is the best way to do this? For example, say the ITEMS class has an IsDirty property and I would like to set that if ANY of the contained SINGLEITEM objects is modified, what's the best way to go about doing this?

I know I could add a reference to the collection class in each SINGLEITEM class (since I override the ADD method, I could make this assignment), but this seems like overkill.

View 1 Replies

Call Method Base Class In Program Passing Sub Class Objects?

Apr 22, 2012

Base class has one field to hold numeric balance value. With 2 methods that accept arguments for adding and subtracting the new input calculating new balance. Sub class has four fields dates, transaction, memo and amount.I have a deposit form, and withdraw form. Each time one transaction is entered it creates an object with sub class fields, then adds to the account collection. My problem is not understanding how to call the deposit/withdraw method and pass the current transaction amount back to the base class to alculate the new balance. Does anyone have any links to information/tutorials on how to perform something like this? As you can see with my code I have tried various different approaches without any success.

[Code]...

View 5 Replies

Class That Inherits Another Class In Which There Are Objects That Are Disposed In Dispose Procedure

Feb 14, 2010

If I have a class that inherits another class in which there are objects that are disposed in the dispose() procedure, do I use mybase.dispose? ex Class A inherits Class B. [code]

View 2 Replies

Storing Process Objects In Variables?

Oct 15, 2011

In a program I've been working on I would like to start a process and save it in a variable of type Process. This is so I can kill it later, if needed, and change the window type.

View 2 Replies

Base Class Collection With Sub Class Objects

Jul 19, 2010

[code]The reason that this is a problem is that this is a collection of EventBase objects, but I'm trying to populate it with child classes instead. For example, I might have a JumpEvent class that inherits EventBase, and this is being put into the EventBaseCollection. That means that value.GetType() returns the type of JumpEvent, which as you might guess does not equal the type of EventBase.The goal of course is to simply loop through all of the various events without having to know anything about the sub-classes. Is there a way to determine the type of the base class so that the OnValidate call will work? Or is this just the wrong way to go about it altogether?

View 2 Replies

Create Objects Of C# Class From Program Class In DNN?

Feb 23, 2011

Can we create objects of a C# class from a VB.NET class and vice versa?

View 2 Replies

IDE - Upgrade To 2010 Projects Referencing A Class Library Targeting A Different Framework Fail To Build

Aug 18, 2010

Say I have a Framework 4.0 project that is referencing a class library targeting 3.5. The project will simply not build. It won't give me any valid error message it will just act as though the reference does not exist.

Projects that were working like this in Visual Studio 2008 are no longer working in 2010. Took me forever to figure out what there error is. If I remove the project reference and add it back the intellisense lights up and you can tell a variable referenced in the class library is found. But as soon as you build the project everything is lost. My using statements get underlined, references to the variable all turn grey and project fails to build saying the class cannot be found. Once I make the class library 4.0 as well everything builds. I get the same issue between 4.0 client profile and 4.0 as well.

View 1 Replies

Literal Substitution - Instantiate Form Objects Using Variables As Literals

Oct 23, 2008

What I need to do is create comboboxes populated with values from a CSV for each class object selected from an Active Directory schema.

So lets say twelve classes are selected, the next form will display the class names in a checkedlistbox and will require twelve comboboxes for associating AD classes to CSV fields. Since the number of AD classes selected will always vary, is there a practical way to code it so that the objects can be instantiated from values stored in a variable?

Other languages support macro substitution, where the variable's value is interpreted as a literal at runtime. Developing in Visual Studio 2005, VB version 8 .netFramework 2.0xxx

View 2 Replies

Use Derived Class Shared Variables In Shared Methods Of Base Class?

Jun 4, 2010

I am trying to add shared members in derived classes and use that values in base classes...

I have base

class DBLayer
public shared function GetDetail(byval UIN as integer)
dim StrSql = string.format("select * from {0} where uin = {1}", tablename, uin)
end function
end class

[Code]..

currently there is error using the tablename variable of derived class in base class but i want to use it i dun know other techniques if other solutions are better then u can post it or u can say how can i make it work? confused...

View 2 Replies

Variables In A New Class

Oct 18, 2011

I have some variables in my main Form, but I want them in all my other forms, how can I make them kinda global or something?

View 1 Replies







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