Assign A Value To The Variables In The Class File?

Jan 28, 2009

I have a class file, myClass.vb. Here is an example of the file:

Private _active As Integer
Private _categoryID As Integer
Property active() As Integer

[code]....

when I want to assign a value to the variables in the class file, should I assign them like what I have in line 24, and 25 or line 28 amd 29? how I assign the variables in terms of performance?

View 2 Replies


ADVERTISEMENT

Assign External Value In Variables?

Jul 11, 2009

i remember that in Qbasic i could assign values to variables from a text file. (not in the code inside.). How to make the same in VB.NET?

View 5 Replies

Assign Variables From Split?

Jun 28, 2009

I have this string, it's "x/y". How can I use the split function to rid the / and assign the x to myVariable and assign the y to myVariable2

View 1 Replies

Assign Variables Dynamically In A Loop?

Jun 20, 2009

I need to assign variables dynamically in a loop. In php you would use curly brackets but this doesn't work in vb.

Dim i As Integer
For i = 1 To 12
lblMonth{i}.text = 'whatever
Next

Anyone know how I can escape the the i variable so it becomes part of the string that precededs it?

View 7 Replies

Database And Split And Assign Them Into Variables?

Feb 23, 2010

How do I read a line in a database and split and assign them into variables?As of now, i can only load the entire database into a variable

sql = "Select * from MenuDatabase" How do i read the database line by line and spit the lines according to column?

View 1 Replies

VS 2010 Assign Same Value To Multiple Variables?

Nov 19, 2010

What is the cleanest way to assign a value to multiple variables? For example, how can I assign FALSE to each of Label1.Visible, Label2.Visible, Label3.Visible, Label4.Visible, and Label5.Visible.Is there anything like

code
Label1, Label2, _
Label3, Label4, _

[code]....

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

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

Assign Selected WPF Datagrid Row Columns To Variables?

Apr 18, 2010

I have a datagrid with customer data such as ID, name, email, phone etc.When I select a row (with a button or selectionchanged) I want to store that row's columns in variables like

dim email as string
dim name as string
email = dgCustomers.theselectedrow.theselectedcell

[code].....

View 1 Replies

Assign The Results Of An SQL Query To Multiple Variables In .NET?

Mar 30, 2012

This is my first attempt at writing a program that accesses a database from scratch, rather than simply modifying my company's existing programs. It's also my first time using VB.Net 2010, as our other programs are written in VB6 and VB.NET 2003. We're using SQL Server 2000 but should be upgrading to 2008 soon, if that's relevant.I can successfully connect to the database and pull data via query and assign, for instance, the results to a combobox, such as here:

[Code]...

How do I execute a query so as to assign each field of the returned row to individual variables?

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

Assign A Value To A Class From A Method Within The Class

Feb 13, 2012

I know this is possible, and it is probably something simple that I am missing... I have a fairly complex class to handle deserialization of an XML file. I wish to place a [class].loadfile method within the class. It looks something like this: Serialization decoration left out for simplicity...

[Code]...

The Deserialization is working just fine (that's my own code), but assigning the object value to Me is not correct. What I want is for an instantiation of this class to have a LoadFile method (similar to the XML class LoadFile method) - but I cannot figure out how to set the value of the class from within the class.

View 3 Replies

Assign A Value To A Self-made Class So That Can Use It Without An Error?

Jun 2, 2011

I have made a class that represents people. When I create a new person, it causes an warning saying "Variable 'NewPerson' is used before it has been assigned a value. A null reference exception could result at runtime"

HOW I have tried to fix it.

I have tried adding value to many of the properties, but it still says that.

WHAT it is like.

It is almost like I have a string with a value of null.

View 2 Replies

Assign To Variable If Inherits From Class .NET 2.0

Mar 31, 2009

I think I remember reading somewhere that it was possible to assign items to a variable if the item inherited from a base class, but I can't remember how.

I want to have a class that gets properties set and one of the properties is an error code property. I want to assign any exceptions that occur to the property, but it could be any type of exception. I remember that all exceptions inherit from the Exception class.

How can I assign an exception to a property based on the class it inherits from?

View 4 Replies

Can't Assign Class Property = DateTime.Now?

Oct 6, 2011

I have a class named clsBatch that has a public property named prpInsertDateTime. If I hover over DateTime.Now while in debug mode the value is "#10/6/2011 9:41:04 AM#" For some reason when I run the code below clsB.prpInsertDateTime = "#12:00:00 AM#". Why is this happening? Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click

[Code]...

View 2 Replies

Assign Class Property As Display Data Member In Datagridview?

Jun 15, 2010

I am trying to display my data in datagridview. I created a class with different property and used its list as the datasource. it worked fine. but I got confused how to do that in case we have nested class.My Classes are as follows:

class Category
property UIN as integer
property Name as string

[code].....

View 2 Replies

Assign Value To Property Of A Class Having Pairs With Attribute Names And Values

Jun 21, 2010

I have valued pairs, attributes names and values in one hand, and I have an object with attributes. I need to set the values of those attributes. I need something like [code]

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

Declaring Variables In A Class?

Mar 5, 2010

What's the proper way to declare variables in a class? I've been doing something like:

'in a class
public shared teststring As String = "first"
'on a code behind

[Code]....

with shared variables loading a second window or reloading the page (without clicking the button) renders the hello world string. so how do I declare variables in a class but make it per instance?

View 5 Replies

Iteration Of Class Variables?

Sep 23, 2011

Background: I am working on an ASP.net project that basically fills out a form from user input. The generated form (for reasons which I have no control over) must be a JPEG or TIFF. So the user fills out the web form, which takes all of the input values and meges them into a blank image (jpeg) of the form. Using System.Drawing, it merges all of the text onto the form at designated Points. The points are defined as variables which are modified at runtime to compensate for the resolution of the image (in case it get modified/re-generated at a different dpi). All of this is working fine.

Problem: Currently I have a Sub that determines the dpi of the master image, then adjusts the Points accordingly. However, there are ~50 variables that have to be adjusted. So currently I have the Sub go thru each point variable and manually adjust the X & Y values. I have been working on a Sub that will iterate thru all of the Point variables and do adjustment. Here's a functional sample of what I have working:Imports System.Drawing

Partial Class test Inherits System.Web.UI.Page

[Code]...

This works...sort of. It allows me to grab each variable and modify it, but only in the instance. The original variable in the class is unchanged. Which means that when the program gets to the point where it's drawing text to the image, the points are unmodified. my basic question is: Is it possible to modify the original variable using this sort of process? If not, is the best way to use these modified values to declare the new class instance at a global level, then have the Sub that draws the text use the instance versions of the variables?

I realize that I could define all of the points in an array which would be easy to loop thru and update, but I've named each point variable something meaningful to correspond to the related text to be drawn.

View 1 Replies

.net - Override Variables Declared In A Class?

Dec 16, 2010

I'm trying to create a generic Controller Class for generic events. But these these events still need to access their class variable. So my idea is to create the Base Controller Class with a ModelBaseclass variable as _ClassVar, which is inherited by all of the other class Controller classes will derive from. But I want the derived controller classes to override the _ClassVar with whichever one they need.

I want to do this, so the ControllerBaseClass can have all the generic functions that all the Derived Classes would use.

Model :

Public Class ModelBaseClass
Public Overridable Function Foo() As String
Return "Name"

[Code].....

View 2 Replies

Access Shared Variables Of A Class?

Jul 23, 2009

I am making a small application in which i have added a class module and a window forms in vb.net. i want to acess the shared variables and mathods of class without making any object.

View 8 Replies

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

How To Access Variables In Another Class Without Deleting Any

Oct 31, 2011

I have been charged with porting a VB6 project into VB.NET. In vb6, if you were in a class separate to a particular variable, you could access that variable easily:

Public Class Foo
Public k As Integer
End Class
Public Class Bar
k = 12
End Class

In VB.NET, my understanding is that before you can use a variable in another class, you must declare a new instance of it:
Dim foobar As New Foo
This would be fine, but I have to access these variables from different classes and every time I declare a new instance, it wipes all old values from the variables, which I need. I tried using Inherits statements but they presented many problems.

View 2 Replies

Naming For Namespace / Class And Variables

Jul 7, 2009

In the code below, the namespace is called "Navigation" which I think is correct. Then I have a class called "Heading", which by definition is the direction a person/vehicle is truly pointing towards. I think that is also named correctly. In the code below, I have four things I have named:
_WhatToName1, WhatToName2, WhatToName3, and WhatToName4.
The value that gets passed in and stored is a double between 0 and 360 -- essentially the degree value from a circle. For WhatToName3 and WhatToName4, I have seen a lot of places that just use "value" as the name. Is that standard?

Namespace Navigation
Public Class Heading
Private _WhatToName1 As Double
Public Sub New(ByVal WhatToName3 As Double)
Me.WhatToName2 = WhatToName3
[Code] .....

View 18 Replies

Net's Assembly Class Store Variables?

Aug 20, 2010

Ok so here's the story. I have an array of Assemblies which are initiated by [Assembly].LoadFrom() that load a number of DLL's. Upon initialising, a method called InitMain (from the DLL!) is called, which sets a number of variables outside of this method, like here:

Public Class Example
Dim C As Integer = 0
Public Sub InitMain()
C = 50
End Sub

[Code]...

If I call the method Test using that same array of Assemblies somewhere later in the main application (like pressing a button or something to trigger it), it will pop up a messagebox with that says: "C = 0"Why is this? Is it fixable without any odd workarounds?

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

.net - When Are Inline Static Variables Initialized In A Class

Aug 10, 2010

Suppose we have a class like:

Public Class Question
Private Shared _field as Integer = CrazyIntegersRepository.GetOne()
' Some other useful things go here
End Class

And the method GetOne throws an exception... How can we manage that? Is a good practice to rewrite that into a static constructor? When is the GetOne method going to be executed if we leave it there in the inline _field declaration?

View 3 Replies

Accessing Public Class Variables In Asp.net Without Session?

Feb 15, 2012

I am using this example I found to learn how to load class files and access variables through them. This is in a file called Class1.vb in the App_Code folder (this is not an app project):

Imports Microsoft.VisualBasic
Public Class my_class
Public Shared Sub my_sub()

[Code]....

How could I access the vartest variable without using a session, since if this is accessed by multiple functions at the same time the variable can be overwritten I assume. Is it possible to go the other way, where a variable is sent to a class file?

View 4 Replies







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