Implement Variable Class Instantiation?

Nov 22, 2011

I have several similar classes but only want to instantiate one of these classes dependant on a selection from my main form.

View 4 Replies


ADVERTISEMENT

Call Functions Within A Class Upon Instantiation Of That Same Class?

Mar 23, 2012

Is there a way to call functions within a class upon instantiation of that same class? Basically, I have functions within a class, but I want to automatically call some of those functions simply when there is an instance of the class created.

Basically, I have this structure:

Dim instance as new class
instance.function1
instance.function2

[Code].....

View 1 Replies

Instantiation - Equivalent Of A Nameless Variable In C#?

Mar 31, 2011

In C#, you can do this:

new MyClass().MyMethod();

The method is executed and the reference is (typically) discarded since no reference to the object is kept.Is this possible with VB.NET (.NET v4)?

Edit: I suppose this is a better example:

new Thread((x) => doSomething()).Start();

View 4 Replies

Private Variable Instantiation: When Defined Or Within Constructor?

Jun 24, 2010

I don't know if this has been asked before, but we're having a discussion about it today at my job. Should private variables (that are shared/static) be instantiated when they are dimensioned/defined, or is it a better practice to do this inside of a constructor?

Public Class IpCam
Private Const HOST As String = "http://test.com/url/example"
Private Shared _Example As New OurClass(HOST)which one to use?

[code].....

View 4 Replies

Class Instantiation - Getting Too Many Arguments?

Oct 24, 2011

I have a class:
Form
Public Class Form1
Dim teamlist(2) As team
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
teamlist(0) = New team(1, "one", "First")
[Code] .....
Error I'm getting is too many arguments.

View 3 Replies

Add / Implement An Interface To An Existing Class Without Changing Code Anywhere That Call The Class And Functions

Mar 1, 2010

I need to create unit testing project for my current website. The currentw ebsite si written in VB. All unit testing examples are using interface to create mock object. My current VB class does not implment any interface. Can I add interface and implement it to my current class and functions without affecting or changing codes to any pages in my website that call the functions? For examples my current class is like:

[Code]...

View 2 Replies

Does An Inherited Class Automatically Implement An Interface From Its Base Class

Jun 10, 2011

Suppose I have piece of code like this:

Public Interface ISomething
....
End Interface

[code]....

View 2 Replies

Way To Implement IComparable (Of T) Or IComparer(Of T) If Class Is Not A Generic Class

Feb 19, 2010

I am working on a general helper class to sort ListView SubItems. I wrote a base class that has much of the code I need. It includes a MustOverride for the Compare method so that the various inherited classes can implment their own comparisons based upon their type. For the value types, I end up with very similar code such as the following, where x and y are ListViewItems: Public Overloads Overrides Function Compare(ByVal x As Object, ByVal y As Object, ByVal sortColumnIndex As Integer, ByVal sortOrder As System.Windows.Forms.SortOrder) As Integer [code]

View 3 Replies

Class Inherit From Another Class And Implement An Interface?

Jun 18, 2009

class inherit from another class and implement an interface?

View 4 Replies

Implement Class Constructor In VB?

Jul 19, 2010

I just would like to know how to implement class constructor in this language.

View 2 Replies

Implement New Array Class

Nov 21, 2009

I want to modify the base Array class by creating a new class called "FileArray".I have some text files that are read into a string array. Each element in the array is a line from the text file. I want to update the GetValue method by overloading it or overriding it so that it will update some value that will give an indication to what the last line was. I have a couple of ideas on how I can do this:

1) Use a public integer, like intLine, that gets updated everytime GetValue is called.

2) Create a new property of Array, such as "LastLine" that would return the last line number (which would basically be the last index value +1) and then use a public array to store the files (though this is less desirable as the array may be used by several different functions)

An easier way would be to be able to determine the last element that was returned, which is basically what I think I am describing above.

View 2 Replies

What Interface Class Implement

Dec 23, 2009

Say I want to know more about a class mshtml.htmlinputelement for example.Say I want to know. What is his parent classes? What interface the class implement? How do I do so through object browser?

View 1 Replies

Build A Useful Class And Implement It In An Application?

Apr 16, 2009

I am trying to build a class. I am having a difficult time conceptualizing how a class is built and how it works. I want to be able to build a USEFUL class and implement it in an application.

View 1 Replies

Implement Singleton In Parent Class?

Nov 18, 2009

Implement singleton in a parent class.Infact what I want is that All the childs etc. should use same instance of the parent.

I have implemented singleton, Changed the scope of parent class's constructor to "Protected". But in the application when ever the new child's constructor is called i.e. "Dim abc as New Ch1()" the constructor of Parent is called (as it is Proctected and can be access from child).

View 2 Replies

Implement The Player Class Through Plug-ins?

Mar 16, 2009

I've never actually used Reflection, but I've been warned in the past that using it may cause slow performance. My question is what part(s) of it is/are slow.

I'm thinking about creating a board game and I wanted to implement the player class through plug-ins. That way there could be several different player classes (i.e. human players, and several configurable AI classes). If implemented this way, where should I expect performance hits? Only when initializing the player class? When passing arguments to methods in the player class? In the entirety of execution of methods from the player class? Or is it going to affect the whole application?

The reason I ask is that the AI will be extremely processor intensive. Through testing it seems like it may take around 1-30 seconds to determine a move on my quad core (Core 2 Q6600) processor, depending on the effort spent to optimize the move and testing different branches on separate threads.

My concern is that if I implement the AI via a plug-in, the move determination would slow down considerably to the point where it wasn't playable on lesser hardware.

View 2 Replies

Make A Class And Implement Tostring?

Jan 10, 2010

If we make a class and implement tostring, should we support some interface?

View 5 Replies

VB Class Library : How To Implement In Tabs

Mar 15, 2012

i cant seem to find an answer to, i recently decide to start using class libraries, but cant seem to figure them out. I need to be able to assign the class details to fields within my texboxes and controls found in the Tab, i have placed an image with a basic layout of the controls on the tab. My question is: 1stly how do i make it so that the class library performs the function within the tab without having to create a seperate form for it with its own controls(or do i need to do that?)Secondly: In the next tab, can i create a seperate class library for it if it performs another task such as issue? how to create and place them as refferences, i just cant figure out how to marry the controls?

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

Class 'QueryParameterComparer' Must Implement Function Compare?

Nov 5, 2011

Im getting the following error on the code I transleted from C# to VB.NET below (original code can be found here:

Class 'QueryParameterComparer' must implement 'Function Compare(x As oAuthBase2.QueryParameter, y As oAuthBase2.QueryParameter) As Integer' for interface 'System.Collections.Generic.IComparer(Of QueryParameter)'.

[code]......

View 1 Replies

Implement - Public ReadOnly Property Within A Class

Feb 24, 2009

How does one implement something as Public ReadOnly Property within a class.

CODE:

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

Use An Existing Class To Implement The Standard DES (using ECB) To Encrypt DES File

Jul 27, 2010

link that implements DES algorithm with CBC. if I want to use an existing class to implement the standard DES (using ECB) to encrypt file, how do i do? I want to use this class because it implements each step of the algorithm.

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

Object-Orientation - Implement The Class And Access The Database For Values?

Dec 17, 2009

I've now properly started implementing OO into my system (which I probably should have done from the start) but I just want to clear some best practices.So let's say I have a class called Job which contains information such as Description, Project Manager (Employee class), Value etc. at the moment, if I initialise the Job class it will initialise all the information held within it, even if I only want the job description. Is it best practice to do this or is it better to implement the class and access the database for values as and when they're needed? Or is it just better in those cases to just access the database directly?

View 1 Replies

How Variables Declared With Protected Access In A Base Class Are Used To Implement Inheritance

Jul 29, 2010

how variables declared with protected access in a base class are used to implement inheritance.

View 1 Replies

IDE :: Modify A Database Class Called TermsDB To Implement The TermsService Interface?

Nov 22, 2010

I created an interface - TermsService.vb and defined the following method : Function GetTermsList() As List (Of Terms)

how do I modify my TermsDB class to implement the TermsService interface I've just created? Here is my code: Have I implemented it correctly?

Imports System.Data.SqlClient
Friend Class TermsDB
Implements TermsService

[Code].....

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







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