Creating Instances Of Own Class At Runtime?

Sep 3, 2011

info on creating instances of my own class at runtime. Simple project for family recipes but would like the option to add new recipes with new instances of my own food Item class at runtime. Creating my own class,no problem. Storing the data in an XML file, OK on that as well. My issue is creating new instances of different food item class as I use this program over time

View 13 Replies


ADVERTISEMENT

Creating Instances Of A Class That Has Several Readonly Properties?

May 24, 2011

What is an elegant way to create and initialise instances of a class that has several readonly properties? Passing all values in a constructor would not be very convenient.

The purpose is that instances are immutable after initialisation. However if the constructor is not used for initialising all the property values, then how can the readonly properties be changed from another class?

View 2 Replies

Creating An Array Of Instances Where Instance Could Be Base Or Sub Class?

Oct 31, 2011

I have a class structure and am attempting to create an array of object instances from the class some instances are parents and some are children Code snippets,

Parent Class object
Option Strict On
Option Explicit On
Public Class cTransportItem

[code]....

View 1 Replies

C# - Dynamically Creating Objects At Runtime That Inherit From A Base Class

Apr 27, 2010

I am writing a game editor, and have a lot of different "tool" objects. They all inherit from BTool and have the same constructor. I would like to dynamically populate a toolbox at runtime with buttons that correspond to these tools, and when clicked have them create an instance of that tool and set it as the current tool. Is this possible, and if so will it be better/easier than creating those buttons by hand?

View 3 Replies

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

Creating Instances Of An Object?

Nov 21, 2006

I'm trying to create 3 instances of the the Workshop selector form for the 3 individuals that I have inthe listbox to appear when I first run the program.

View 4 Replies

Creating Multiple Instances Of A Form?

Aug 12, 2009

I have a form (form1) and I havea button on form1 (button1) that will start a second form (form2).How can I make it create multiple instances of form2 when button1 is clicked?i tried a process module that the studio comes as standard but it does not allow me to start multiple instances...how can i do this?

View 14 Replies

Creating Object Instances Globally?

Nov 19, 2009

this is probably something I should know, but I'm puzzled by this.I'm trying to create some objects and being able to access and modify these globally. I tried to create a Public Module and declare a few objects in this.I am able to access these from another sub, but I get an exception error when after building and runing the process and trying to modify these object. The same thing happens if I declare the object in the Public Class Form1. For example like this:

Public Class Form1
Public appWord = New Microsoft.Office.Interop.Word.Application
Public wordDoc as Microsoft.Office.Interop.Word.Document

[code]....

View 1 Replies

MEF Import Is Creating Two Instances Of Every Part

Nov 25, 2011

I am using MEF to compose a number of components at run time but when I use a metadata attribute it double the number of parts in the collection.

When checking the container.ComposeParts I can see that the dll containing the 11 implementation of IStages is loaded once and only the 11 part required appear but when it resolves the Private Property Stages As IEnumerable(Of Lazy(Of IStages, IStagesMetadata)) the number of instances is doubled to 22. Looping through the collections I can see that they are duplicated by the ID in the metadata.[code]...

View 1 Replies

Creating Multiple Form Instances In A Subroutine?

Aug 23, 2010

I am trying to create a subroutine that creates multiple instances of a specific form.

Here is my code:Public Sub NewFormInstance(ByVal FormName As Form)

Dim FormInstance As New FormName
FormName.Show()
End Sub

View 3 Replies

Creating New Instances Of Form1 With Variable Properties

May 13, 2009

I'm trying to elaberate on some basic examples of .Net programming in using VB. The basic example of creating a new instance of Form1 is:
Dim x as New Form1
x.Show
I've added some OptionButtons to set the StartPosition of the Next Instance of Form1 as well as some Labels that display the Top, Left, Width and Height properties when the new instance of Form1 is Shown.

This is the code I'm using.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As New Form1
If Me.RadioButton1.Checked = True Then
x.Top = 0
x.Left = 0
[Code] ......

View 1 Replies

VS 2008 - Creating Instances Of Controls On Form?

Sep 14, 2010

Is it possible to create instances of controls on a form ? Of course I mean visually , not just by code. After all, these languages define themselves as "Visual" so they should provide that possibility. It is important for the instances to be visible during design time because otherwise we could only guess where those controls might "land". Nevertheless , I have the feeling this is not possible in VB .NET but still I thought I should ask first ...

View 11 Replies

VS 2008 Multithreading Or Creating Project Instances

Feb 15, 2011

I have been trying to create good multithreading programs and it is not working well considering the use of global variables, local variables etc and thread safe controls. I have not found a good way of doing it since it seemed to be not as efficient as just running it on a single thread.

The program accesses facebook and twitter api, parses etc. and I am wondering if I can just create new tasks and map the program project file and fire new instances of the project. Someone this using the taskfactory in 2010 but I thought this was just the same as the threadpool. on this: create windows services and set them to run on task scheduler??

View 2 Replies

VS 2010 - Creating Multiple Instances Of Subs

Jul 31, 2011

I'm creating a twitter account manager using the Twitter API. I have multiple accounts, over 10 of them. I want to automate all 10 of these accounts to do certain things, now the way I started to code the program was so that it would accommodate only one account, and all the codes worked perfectly and were managed by individual timers for individual processes that I wanted done. i could tweet between certain intervals, follow people who tweet certain things without me being on top of it.

Now the problem is that I've been trying to create new instances of subs that I've already created so that I dont have to create 10 new subs with the exact same procedures. I'm pretty sure it's impossible to create copies of subs dynamically or within a loop but it didn't stop me from trying. So question is how can I edit a program that was designed to accommodate and automate only one account, to potentially accommodate over a 100? I don't need codes or anything I need ideas so I can try them, but right now I'm completely blank.

View 2 Replies

Multiple Instances Of Class?

Mar 29, 2010

I have the following problem. (VB.Net 2008)I have created a class (myFirstClass). In this class there are a lot of calculations being made wich gets fired by events in that same class.Now i want that same class to be able to fire more instances of itself. However i noticed that each time i fire an event from a Sub the program waits till the event is finished before going to the next line of code. This is a problem since i want the event wich fires a new instance of the class to fire it and forget about it.

View 7 Replies

.net - Allow Math To Occur On Instances Of Class?

Nov 27, 2010

Is there some interface I can implement to allow basic comparisons and math to happen as it would an integer?

For example, let's say I have the following class:

Public Class Something
Public SomeBigNumber as UInt64
End Class

I would like to do something like this:

Dim SomethingA, SomethingB, SomethingC as New Something
....
If (SomethingA-SomethingB) > SomethingC Then
'Do stuff
End If

I was hoping to be able to implement some interface (if that is even the right term for it) that would return the UInt64 contained in the class for comparison and math, if possible.

View 1 Replies

Added To Each UserControl (different Instances Of The Same Class), A Little Map?

Apr 28, 2009

I have a form whose purpose is to let the user to load map files.The form may manage a variable classes of maps, and each class have his own UserControl.To make it more user friendly, I added to each UserControl (different instances of the same class), a little map, showing a small picture of the map, and some data, as bound coordinates.

The problem is, that it looks really ugly. The maps are so big, compared with the rest of the UserControl (who contains just a button and a textbox to search for files).I wish to fix it, but I din not see an elegant way to include the pictures and info.I attach a form screen capture with two UserControl.I would like to get some tips for more experienced users. There are some guidelines?

View 5 Replies

Multiple Instances Of A Custom Class?

Feb 15, 2009

I have a sub that runs on a button click which I want to create a new instance of a custom class and add it to a list of already created instances of this class. I want the result to be a List Of collection of all of my class instances.

My problem is that each time I run the sub, it simply 'overwrites' the first instance of the class and adds a copy of it to the list instead of writing a new instance. My code is along these lines

dim objFixture as new clsFixture
For n As Integer = 1 To intNoOfChannels
objFixture.SetChannelAddress(n, intCurrentChannelTotal + 1)
intCurrentChannelTotal += 1
next
lstFixtures.Add(objFixture)

View 7 Replies

Passing Variables Between Instances Of A Class

Jun 17, 2009

I created a program a while back, in the traditional VB.NET way by drawing a bunch of forms. I have started playing around with creating the forms at runtime using classes. I have a placeholder form called frmStartup which merely calls the CreateLogin() sub from the CreateFormClass. The CreateLogin() sub creates a new blank form, then calls the grpbxLogin(), btnSave() and btnExit() subs from the FormElementClass which adds all the buttons and textboxes to the form. Within the FormElementClass, I have associated btnSave and btnExit with event handlers. These even handlers call subs from the DataProcessingClass. The event handler for Exit works just fine.I am having a problem with the Save event handler. Precisely, I don't know how to pass either the username or password from the Login form to the btnLogin_Click() sub in the DataProcessingForm. I have tried using Me. and frmLogin., but the program doesn't see either of those. If the Login form is an instance that is disposed of once another Sub is called, then it won't exist later on to call from. I have tried declaring variables and passing those along to btnLogin_Click, but no matter where I put it, the program doesn't see txtbxUsername.Text or txtbxPassword.Text. Not even from within FormElementsClass, which is were the boxes are created.Any ideas on how to pass variables in this case? I am not even sure what you would call this such as passing between classes, or passing between instances.[code]

View 9 Replies

Repor Declaring Class Instances?

Oct 20, 2008

I've decided to forget the d@mned custom code because everything I do with comes up with errors I don't know how to fix and it seems no one else does either. Or they do and they're keeping to themselves.

I put the functions that I needed to use in a class called MsgBoxOperations. The file name is MsgBoxOperations.vb In the report, up on the standard bar where file, edit, view, and all the other stuff is, is one that says report. You click that and go to report properties and it brings up where you can name the report and put in custom code...(hate custom code right now...) and where you can put references and class instances. Clicking on the Reference tab brings up wher you put in your references and classes.

In the classes area it asks for the Class Name, which I put in MsgBoxOperations, and the instance name of that class, this case mbo. I get that far and put in those two things and save it. Then I go to the textboxes where the values need to be. I put in the text box: =Code.mbo.GetStartDate

I've already tried taking the Code. part out and it screams that mbo isn't declared. So it does have to be there. I go to run the code and comes up with this error: QuoteError in class instance declaration for class MsgBoxOperations: [BC30002] Type 'MsgBoxOperations' is not defined.

I've posted before and still have received no help or someone tried to help but then stopped when their suggestion failed and then no one else wanted to help. I've googled this problem to the point where every link that it comes up with I have already clicked and found their information useless. I've got a freaking migraine because of this issue and have been in tears over it more than once.

View 14 Replies

Alphabetize An Array Of Objects That Are Instances Of A Class?

Nov 1, 2011

I have an array of objects 2000 that are instances of a class. I want to alphebatise these objects by a detail of the class.

View 1 Replies

C# - Respond To Events From A List Of Class Instances?

Jan 21, 2011

I have a .NET class, InstrumentConnector, that has an event, StatusChanged. I want to create several instances of this class (each class handles a separate file) and respond when the StatusChanged event is raised any instance. How would I do this in .NET? Do I want to create a List(Of InstrumentConnector) or a similar IEnumerable? How do I write the event handler to respond to a particular instance's StatusChanged event?

Here is the InstrumentConnector class and the module with the StatusChanged handler:

Public Class InstrumentConnector
Private _inProcessDir As String
Private _doneDir As String

[Code].....

View 2 Replies

VS 2010 'Infinite' Public Instances Of A Class?

Jan 24, 2012

I'm a little out of my comfort zone here having programmed in VB6 quite a few years ago things have changed a lot since then.My issue is I have a class that I've built which works with no issues but I would like to be able to keep a 'handle' of some description on this class so I can also make adjustments to it's parameters when the user changes something. My problem is that I need to do this for an unknown quantity of these class instances.

In the VB.Net language how would I create an instance of this class that could be accessed by any Sub within the application and each instance created can be individually accessed by specifying some sort of identifier?

View 2 Replies

Ensure Instances Of Class Finish Before Main Terminates?

Feb 14, 2012

I have a MultiThreading issue and conceptual question using Visual Basic (but it applies to almost all languages). [code]...

View 2 Replies

MovablePictureBox - Set The Flags In All Other Existing Instances Of The Class, When It Is Set To True In The Selected PictureBox?

Apr 17, 2010

if I have several of these movable PictureBoxes added to a Form (Form1) and want to display a selection rectangle only on that PictureBox, that is just selected,then I think I should use a flag to mark whether a PictureBox is selected or not. The flag could be used in paint event to decide,whether the selection rectangle is to be drawn or no .To add a flag property to the new class is no problem. But how can I set the flags in all other existing instances of the class, when it is set to True in the selected PictureBox?

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

VS 2010 Sorting A Listbox (after Trying To Copy Class Instances Properties To A Temp List)

Jan 25, 2012

I'm trying to figure out a way to sort the entries of a listbox... but in a different way instead of the obvious one (sorted property). First of all, I need to explain how the items are populated at first:

[Code]...

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

Creating An SQL DB Connection During Runtime?

Nov 22, 2009

Needing pointed in the right direction. I am fooling around with data sources and connections per homework and what I'm looking for is creating an SQL DB connection during runtime. I know that you can add a data source in design by going through the Wizard but what if one would want to create the connection, adapter, and dataset during runtime? Where would you start?

I have cruzed the net looking for some form of a tutorial to just get me started, I don't need it all completely outlined but I need to know where and how to start and what I need to declare the connection, string, and dataset as. I have seen a lot of information using VB6 but nothing that I come across seems to work.

My basic questions are:Do I have to create a seperate class for the database connection?How do I delcare the nuts and bolts of the connection,adapter, and dataset?If a seperate class isn't required then where is the most realistic place these items would be created?

View 1 Replies

Creating DSN Entry At Runtime?

Aug 9, 2010

How can you add a system DSN with its security credentials programmatically at runtime from VB.NET? Keeping key in ODBC.INI is done, but when creating ODBC, it asks for Authentication Type (SQL or Network Login).How can we set that option at runtime?

View 2 Replies







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