Define A Class Such That There Can Be Only A Single Instance Of That Class?

Jan 20, 2012

Is there a way to define a class such that there can be only a single instance of that class?

View 5 Replies


ADVERTISEMENT

VS 2008 Define A Class As An Instance?

Apr 17, 2010

I would like to define a class as something like a constant, and use the class directly rather than having to always create an instance. Is this possible? I've tried a handful of combinations of syntax, but nothing I've tried lets me do what I'm after. To give an idea of what I'm after:

[Code]...

View 7 Replies

Can't Define A Specific Instance Of Static Method Created As A Java Class

Mar 12, 2011

Under Visual Basic 2010, I am trying to define a specific instance of a static method that was created as a Java class. I have a vendor supplied dll added in as a reference.[code]...

But, I can't seem to define a specific instance of this method. Using "IntegrationMethod.getIntegrationMode()"always returns a value of zero.

There doesn't appear to be any way to "setIntegrationMode" to a specific value.

The documentatoin for this Class as provided by the vendor are shown below.

When I asked the vendor for assistance, their response was: "

Our javadocs for the IntegrationMethod class show that we provide three predefined instances of the IntegrationMethod class[code]...

View 9 Replies

Create A New Class That Inherits From The Base Form Class And Define A New() Method With Parameters?

Oct 1, 2008

I've been creating short test apps repeatedly to try to understand some of the concepts in VB.NET.For the most part it has been illuminating.I read Bucky's .NET knowlegebase tutorial on passing objects as parameters to newly created forms. He shows how to create a new class that inherits from the base form class and define a New() method with parameters Extending the concept I thought about doing the same thing with a form that was created at design-time (In this case Form2).

[Code]...

View 6 Replies

Class Library (dll) Single Instance To Pass Data Between Processes Or Exe's DESIRED BADLY

Oct 20, 2010

The "named pipe" seems rediculous to pass data between processes (exe's). Is it possible to run a single instance of a VB.NET Class Libary (dll) such that two programs can access the same memory resident dll, thereby passing data via functions and or subs?When I try to make the class library as single instance, the "Enable Application Framework" is greyed out, and thus the option to "Make Application Single Instance" is also greyed out.When I try to call the dll from two processes, I simply just create two instances, so storing data in a module doesn't work

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

How To Assign A Different Reference To A Class Instance From Inside The Class Code

Jan 18, 2011

my proble is the following: I have a class MyClass and another class Modifier, which has a method ModifyMyClass(ByRef mc as MyClass) that receives a MyClass instance as ByRef parameter to modify it. A smell of the code is:

[Code]...

View 4 Replies

Class With Class Properties: AObject Reference Not Set To An Instance?

Aug 19, 2009

I have a class in which some of the fields are also classes.I can put values in the "normal" properties, but in the others when o try to assign values it gives the: "Object reference not set to an instance of an object"But the code compiles fine.

dados_Defenicao = New ServiceReference1.draftClaimEntryDefinition
dados_Defenicao.arCode = "123"
dados_Defenicao.claimMarket.warrantyType = "w" - Here it gives the error

How can i fix this ?

View 6 Replies

Class With Class Properties: Object Reference Not Set To An Instance

Aug 19, 2009

I have a class in which some of the fields are also classes.

I can put values in the "normal" properties, but in the others when o try to assign values it gives the: "Object reference not set to an instance of an object"

But the code compiles fine.

dados_Defenicao = New ServiceReference1.draftClaimEntryDefinition
dados_Defenicao.arCode = "123"
dados_Defenicao.claimMarket.warrantyType = "w" - Here it gives the error

View 4 Replies

Declare A RANDOM Class Instance At CLASS Level?

May 6, 2010

If you run this code you will see that the 500 PictureBoxes that are added ( this is easier to show than adding pixels as a pixel is only a single point ) fall mainly on the diagonal.With regard the RANDOM class, why should this be like this when the bounds of the instances are? >>

p.Location = New Point(x.Next(0, Me.Width + 1
), y.Next(0, Me.Height + 1 ))
as in this code.>>

[code].....-2138214fdeb4

View 9 Replies

Creating An Instance Of A Class From A Class Library?

May 18, 2010

I've createda vb.net class library where I've defined a number of small classes... nothing complicated, just working with strings, sending emails, etc.In another project, I reference the class library and I'm seemingly able to create an instance ofone of tclasses - intellisense shows me all of the plic properties, methods, etc... all looks perfect. No compile errors at all, nothing b gumdropsand lollipops.When I run the app I'm working on that references the class library, it fails at the point where I'm creating an instance of the class and gives me a vague exception, "System.TypeLoadException".

View 2 Replies

Get A Reference To The Class That Creates An Instance Of Another Class?

May 20, 2010

I need to create a new instance of a class that needs a member of the calling class. But i can't pass a reference to the calling class through the constructor.The solution i am looking for is something like this:

Public Class ChildClass
Public Sub New(args)
_MyMember = GetMemberFromCallingClass()

[code]....

I want this to work without having to manually pass any references or variables from the calling class to the new instance of ChildClass.

View 2 Replies

VS 2010 Class Create Another Instance Of The Class Itself?

Jun 11, 2012

I want to create a class that will "search" for something. Basically I load up the "search item" when the class is created and inside the class is logic to do the "search". The result of this logic will be more "searches" that I want to start. How can I have the logic in the class create another instance of the class itself?

View 3 Replies

How To Define A Twin Class

Oct 15, 2009

I need to do something like this Class A End Class Class B Inherit A End Class A=B If i try i get an exception! that i can not cast B in A. How can I overcome this problem? I need to define 2 classes B identical to A but as a distinct class What I need is to be able to cast one class to the other like A=B or B=A I tried with directcast but i got the exception what can I do

View 1 Replies

Define And Declare In Class Module?

May 25, 2011

below is my code to use binarywriter it work fine on class form1 level

[code]...

View 2 Replies

Define The MyMethod() Within The Class MyCls?

Jul 28, 2010

Interface Iinterface
Sub myMethod()
End Interface
class myCls implements Iinterface
End Class

i did this and i wanted to define the myMethod() within the class myCls but i am getting an error in this line:

class myCls implements Iinterface
error:end of statement required

View 1 Replies

VS 2008 Bind A Single DGV Cell To A Single Class Property?

May 7, 2010

I am trying to use the DGV to view various properties from a variety of different class instances. Is it possible to bind each cell individually?

View 9 Replies

Define A Property In Class Which Is An Array (of Doubles)?

Feb 6, 2012

I need to define a property in my class which is an array (of doubles).My original (bad) version is this:

Public Class Market
Property Correlations0 As Double
Property Correlations1 As Double
Property Correlations2 As Double

[code].....

This however doesn't work. I get an error already at design time: "Public Property Correlations as Double has no parameters and its return type cannot be indexed."What should I do with it? I also do not know in advance how large the array should be (the array size is determined at runtime based on other properties).

View 8 Replies

Define The Base Class Of A Form At Runtime?

Apr 29, 2010

I'm developing a software that handles very specific regional standards. In one part of the country they have different standards for entering this data than they do in other parts of the country. In fact there are hundreds or thousands of possible configurations that would be best in various regions.

The solution I've come up with is to write a program that can load different control configurations with the supporting code to its main form at runtime. I do not know how to accomplish this. Would I use visual inheritance at runtime? Would I use a plugin system? I just need to potentially allow a power user to design thier own interface or to modify an existing interface to better suit thier needs.

Edit: Is there a way to define the base class of a form at runtime? Could I create user controls in a plugin and pass them in to the host program?

View 3 Replies

Define A Main Method In A Class Versus A Module?

Jul 12, 2011

I was just practicing some coding and noticed that I was able to use class instead of Module in VB .NET. So I replaced my module to class and I got this error message:No accessible 'Main' method with an appropriate signature was found in 'practicevb'.practicevb

I made sure that the startup object was set correctly in Properties > Application > Startup Objects.The error message disappears if I change it back to Module but I would like to keep it class since the other parts of my code I changed to class and didn't return and error messages.

Class Atic
Sub Main()
Console.WriteLine("Hello, this proram will calcaulate the quadratic forumla ax^2 + bx + c")
Dim Quads As New Quads

[code]....

View 4 Replies

VS 2008 PropertyGrid Class Properties - Define The Color

Oct 21, 2009

1 - Need to create a kind of composite property, like the font property, that it's showed with a plus sign to expand. For example i need to define a new pen, i need to define the color and the width... 2 - I need to define the color for one brush, but if i create a property of the type brush in the PropertyGrid it appears like "System.Drawing.SolidBrush"

View 2 Replies

Object Oreinted Random Failure - Define Two Instances Of Class And Configure ?

Oct 27, 2009

I am having a problem with a and OOP class i made that contains a sub that creates random integers.

Problem is if i define two instances of this class and configure them(name in this case) then they both display different names but the random integers are ALWAY the same. in this case having the integers the same kinda kills the idea of the program.

Is it possible that the random part only every works for one class, but if .NET is fully OOP then this should not be possible... right?

Some of my Code (broken down to something smaller) i will display for obvious reasons.

Code:

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

Get Class Name Of A Instance?

Aug 20, 2010

Is there a way to get the instance's class name with VB.NET?

View 2 Replies

Add Instance Of Class That Contain Data

Jul 16, 2009

I have been asked by a code snippet to add the instance of class that contains data i want to add to an XML file, the only trouble is i am not sure what an instance of class is. Is it something that looks like this: [Code]

View 2 Replies

Cannot Create An Instance Of My Class

Feb 24, 2010

I am working on an ASP.Net 3.5 solution that I did not originally build. I added a class file named Incident.vb to the App_Code folder like I always do.But in my code behind of a web page, I usually create an instance of a class like:

Dim oIncident as New Incident

But after I type "New", normally I would see my class file he intellisense but I do not. So it does not seem to be able to find Incident.vb. I have not seen this behavior before. Trust me, my class is correct. I have created many class files like this.[code]...

View 9 Replies

Cannot Seem To Get Sub From An Instance Of Class Once Instantiated?

Sep 11, 2009

I think I just need a push in the right direction. I cannot seem to get my sub from an instance of my class, once instantiated, to run when I click on the button. My Code in the class is

When I click this:Private Sub btnBark_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBark.Click
mydawg.bark()
End Sub

[Code]...

View 2 Replies

Class Function Without Instance?

Mar 24, 2012

I have a Class, which I create an instance of in order to use, however I have a couple of functions (which don't really relate to the instance data) which I want to use when an instance hasn't been created.

Visual Basic .NET (2010)

Example of what I'm trying to do:

' Log a user into the system (this works)
Dim hedwig As New CustomSecurity
hedwig.Login("username", "password")

[Code].....

View 3 Replies







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