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


ADVERTISEMENT

Passing Variables From One Project To Class Library

Mar 10, 2009

How to pass a variable in one project to dll in vb.net

View 1 Replies

Passing Multiple Byref Variables / Variables Fail To Change Calling Funct W/ Invoke

Sep 27, 2010

I have code, shown below, that works all except for 1 thing: The variables being passed byRef get passed, but once modified in the else section of the "if me.invokerequired" code of RecordData, the variables are never updated in the calling function. To reiterate, the calling function does not receive the updated data that is in the variables custid and amt.When debugging, I see the data change in the else section of "if me.invokerequired", but once it returns from the callback the data is missing.[code]

View 15 Replies

Multithreading: Reading/setting Variables, And Passing Variables?

Mar 8, 2011

Question 1: What is the difference between "Background Worker" and "Worker Pool" as indicated within the MSDN samples provided.

Question 2: I noticed while using, AddressOf _Function_, variables cannot be passed; what would be an efficient solution to this?

Question 3: While using multithreading is it required to invoke before setting variables, or only form properties?

Question 4: While using System.Net.Sockets is it safe/efficient to use Application.DoEvents while waiting for new data; or would be using a Do While loop be fine without DoEvents since the action would be multithreaded? Note: there can be up to 2000-3000 sockets in use at a time.

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

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

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

Passing Variables From Sub To Sub

Mar 30, 2010

I have my own little tutorial about passing variables, and if you'll look at the code below, you'll see how I am passing the variable from one sub to the secondsub. Here's my question, how can I pass a value back from the 2nd sub to the 1st? So if I want to sum intA plus intB, and want to return that value to the first sub, how do I do that? [code]

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

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

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

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

Passing Info To Variables

Apr 21, 2011

I have a program that I am writing that asks the user for information.The program takes that info and passes the strings to a module that has a set of case statements for comparison.The program was working just fine yesterday, and now it acts like there is no information being passed to the module for comparison.[code]

View 2 Replies

Passing Session Variables

Jan 21, 2009

I have an ASP.NET 2003 web application. There is a .vb module file within that application. Is there anyway I can pass a session variable into this .vb module from a aspx.vb page?

View 2 Replies

Passing Two Variables To An Executable?

Sep 16, 2009

I have an application I have built which is basically a decision matrix. I would like to add it to a current database as a button on the form. When the button is clicked I would like to pass header information to the executable (two variables).

I can modify the code but I am not sure where to begin?

View 8 Replies

Passing Variables Between Forms?

May 17, 2012

I have a Form1, the user types a "Client ID" in a textbox if it's not a valid one, it opens a Form2 in which the user selects the correct "Client ID", once selected he presses an OK button. And there comes the porblem.. it opens a new Form1 with the Client ID that he selected from Form2, but I still have the first Form1 opened.
I have two Form1 opened...

I which to keep the original Form1, but with the value sent from Form2..

I'm using this code:

Code in Form1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[Code].....

View 2 Replies

Passing Variables From One Form To Another

Apr 27, 2009

I am using Visual Basic 2008 for this assignment. I have a project that I am working on and I need to be able to use form variables across the entire project.

I have looked on other forums but no definitive answers.iI have declared variables as such Public StrV21true As String and "Public StrV21False As String

Now apon assigning a string to the variable with an If Then Else Command, I go to the next form expecting that the assigned variable will be available for use in this second form but to my dismay it tells me that the variable has not been declared and will not even show up in Intellesence. Like I said before from research on the net I am using the public class in Form 1 to hold the variables and am kind of expecting the public class variables to be available through all the forms in the project. I would really like to know how to do this so as I can finish my project for class.

View 4 Replies

Passing Variables Through Classes?

Feb 8, 2012

I'm having trouble passing Variable information through classes, here is what I mean.

Example:
On my Form I call on Test.Result
Test is my Class

[code].....

View 1 Replies

Passing Variables To A Sql Query?

Nov 19, 2010

I have two forms and I'm trying to pass a declared variable from form1 to form2 and then pass that variable in a sql query that I have in a dataset that is bound to my form. I know that my query works but it's not producing any data. I have debugged my form and can see the data being passed in the variables elsewhere on the page but I'm not sure of the syntax within the query.

[Code]...

View 5 Replies

Passing Variables To A SQL Where Clause In VBA?

Jan 24, 2012

I am getting an "Automation Error" with the following:

Dim sheetdate As String
Dim sheetdate1 As String
sheetdate = "7/1/2011 23:59:0"

[code]....

I need to pass two variables to the WHERE clause. If I manually input 'sheetdate' and 'sheetdate1' into the clause -

WHERE (((ticketorders.TimeStamp)>#7/1/2011 23:59:0# AND (ticketorders.TimeStamp),#7/2/2011 23:59:0# ...

everything works fine. The problem is I have multiple sheets and I would rather not have to add the entire sub-routine to each and every sheet. My thought is, it would be easier to create a PUBLIC sub and pass the time values (sheetdate and sheetdate1) to the WHERE clause.

View 2 Replies

Passing Variables To New Form?

May 21, 2009

I've got a form in my MDI container. Lets call it Form1. I now want to show a dialog box (Form2) and pass the primary key from Form1 to Form2. Do i create a public function on Form2 called SetMe() or Do I create a public on Form1 And read from it? From a best Practice point of view, How would you go about it?

View 1 Replies

Passing Variables Within A Web Link?

Dec 9, 2009

I�d like to pass the username and password within a link to a browser using VB code. This link works "http:192.168.0.26:81/forum/login.asp?username=test&password=test" when used manually but not when used within a code:

Dim username, password As String
username = "test"
password = "test"
WebBrowser.Navigate("http:192.168.0.26:81/forum/login.asp?username='" & username & "'&password='" & password & "'")

The username and password are passed onto the web page within single quotes as �test�.

View 2 Replies

Variables Not Passing From One Form To Another

Aug 31, 2011

I am passing 2 variables from form1 to form2. In form2 I want it to where it will filter my dataset according to the variables in form1, before it's displayed. In form1 it works, but when passing those values (JT & WRID1) to form2, it doesn't work.

Form1:
Public Class Form1
Friend JT, WRID1 As String
Private Sub ShowForm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShowForm2.Click
JT = Me.dgvWLog.Rows(dgvWLog.CurrentRow.Index).Cells("dgvJT").Value.ToString
WRID1 = Me.dgvWLog.Rows(dgvWLog.CurrentRow.Index).Cells("dgvWRD1").Value.ToString
End Sub
End Class

Form2:
Dim s As New Form1
Dim JT As String = s.JT
Dim WRID1 As String = s.WRID1
Me.DataSet.Form2_Get.DefaultView.RowFilter = "WT = '" & JT & "' And WRID1 = '" & WRID1 & "'"

View 1 Replies

VB 10 Passing Variables Between Forms?

Apr 12, 2011

I am working on a program, and I would like to have the program pass a name from on form to another.

This is my code :
form 1 :
Public Class Form1

[code].....

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

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

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







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