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
ADVERTISEMENT
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
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
Apr 15, 2012
"Create a class called Invoice that a hardware store might use to represent an invoice for an item sold at the store. An Invoice should include four pieces of information as instance variables--a part number (type String), a part description (type String), a quantity of the item being purchased (type Integer) and a price per item (Type Integer). Your class should have a constructor that initialize for each of the four instance variables. Provide a property for each instance variable. If the quantity is not positive it should be set to zero. If the price per item is not positive it should be set to zero."
I attached the code I have. obj is underlined and says "Argument not specified for parameter 'Invoice4' of the 'Public Sub New (Invoice1 As Object, Invoice2 As Object, Invoice3 As Object, Invoice4 As Object)' and so the program won't run. What am I doing wrong?
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim obj1 As New Invoice(Val(TextBox1.Text))
TextBox1.Text &= obj1.Invoice1 & vbNewLine
TextBox1.Text &= obj1.Invoice2 & vbNewLine
TextBox1.Text &= obj1.Invoice3 & vbNewLine
TextBox1.Text &= obj1.Invoice4 & vbNewLine
[CODE]...
View 14 Replies
Aug 15, 2011
I am using sql in and am stuck. after "selecting * from table", how do i store whatever I have obtained from my database in a variable, for display?
View 2 Replies
May 31, 2010
I have a database in my app which loads and displays some information on a form by binding the Comboboxes and Textboxes. However, I need to get some of the other values from the database for calculations before they are displayed on the form and I can't seem to find out how to do this.I could bind a couple of Textboxes to the database and then use those values to calculate, but it doesn't seem like a very efficient way of doing things.The dataset is created using the wizard and the controls are linked in the UI.
Please bear with me, I'm still a noob.
View 7 Replies
Jun 24, 2010
1. Is it possible to store images in the variables or something like that, then store the images of things that are not buttons, picture boxes or panels?
2. What is the fastest way to store images in Visual Basic?
3. Is it possible to create a list of the class Bitmap and post a picture in each bitmap in a forloop? If it works I would like to see some examplecode.
View 1 Replies
Jul 19, 2011
I have text file that is saved as comma delimited. There are 3 columns with x number of rows. I cannot seem to figure out how to create an array that will store all three columns with the variable intProductArray as the length of the array. I have been opening the file with only one column and putting it into a textbox and using the lines of the textbox as the variable for length. I cannot figure out the array for all 3 columns.
Private Sub btnChoose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnChoose.Click
Dim myFileDlog As New OpenFileDialog()
myFileDlog.InitialDirectory = "c:"
myFileDlog.Filter = "All Files (*.*)|*.*" & _
[Code] .....
View 12 Replies
Jul 9, 2009
I have several threads all relating to this same subject but I have yet got a answer which I could work with. I think most of that is because of my explaining..So..[code]...
View 3 Replies
Dec 4, 2009
Which is the best way to store global variables, in My.Settings or My.Namespace. The reason I ask is because I need to know certain boolean values if certain forms are open from other forms. At present I am defining Global Boolean variables in My.Application, which give the result I require.
View 3 Replies
Apr 15, 2010
I'm creating a calculator in visual basic 2008, and with this calculator I want to implement a feature that can store numerical values in a variable for instance x. Similar to the feature used in most graphing calculator that have the button showing: "STO->". I was thinking on using the My.Settings. But I'm having trouble on it.
View 2 Replies
Dec 24, 2010
My text file is a settings file and I know I will be adding more to it in the future, right now it reads "autoplay=false;mintray=false;"I am currently using probably the most inefficient way to check both of those settings:
if contents = "autoplay=false;mintray=false;" then
elseif contents = "autoplay=false;mintray=true;" then
elseif contents = "autoplay=true;mintray=false;" true
elseif contents = "autoplay=true;mintray=true;"
endif
How can I read the file, find each word from the equals sign to the semicolon, and store each of them in a variable identified by the text before the equals sign? Something like this:
contents = "autoplay=false;mintray=false;"
autoplay = "false"
mintray = "false"
Also, how can I edit the settings in the text file without having to overwrite everything every time I save to it? For instance; finding mintray in the text file, and changing mintray to true instead of overwriting the file with "autoplay=false;mintray=true;".
This is my current
Reading
Dim fs As New FileStream("C:myfile.txt", FileMode.Open, FileAccess.Read)
Dim d As New StreamReader(fs)
[code]....
View 3 Replies
Jul 26, 2010
I am a java developer that inherited a vb.net web application. This app relies on a VB class assembly that builds in to a dll. I have made some changes to this class assembly but I cant seem to get the vb.net app to pick up the changes. I thought that using regsvr32.exe or regasm.exe would do the trick but after reading a bit more they don't appear to do what I need.
When vb.net uses code such as this import where is it getting the reference to "MyClassName"?
<% Import namespace="MyClassName" %>
View 2 Replies
Jul 22, 2010
MY understanding is like this, for the "website type" of projects:for VB, the default setting for the namespaces and the default setting for references are both stored in C:WindowsMicrosoft.NetFrameworkV4.0.30319ConfigWeb.config.
but C# does not seem to use this global web.config file to store its default namespaces and references settings. One evidence is that you see a lot of "using ..." statements at the top of all C# files whereas you don't see many "imports ..." statements at the top of all VB files. So C# stores the namespace settings in individual .cs files, but where does C# store the reference settings then? Or the C# compiler knows all the reference without having to store it somewhere?
View 1 Replies
Apr 29, 2011
I'm using web project and web forms.I create Custom Class
Namespace CustomWebControls
Public Class NoValidationDDL
Inherits DropDownList
End Class
End Namespace
and i try to register this class in assembly web.config page section
[Code]...
View 1 Replies
May 2, 2011
Two of us at our company worked on a VB project. I developed the GUI interface. Another programmer developed some of the Classes that are also part of the project/Solution. Our manager wants to see as part of the 'Help/About' drop down, the version of the GUI application as well as the Class that the other programmer wrote. We are on the third modification of my GUI application, but the 8th version of the class that the other programmer wrote. Is there some way that the GUI application can get the 'Assembly Version' information for a class that may not necessarily exeuting at any given time?
View 3 Replies
Mar 3, 2009
I have a Visual Studio 2008 solution with project A referencing project B as a project reference. Project B references System.Data.Linq, but project A does not. Everything compiles and runs fine. I like this arrangement because avoiding a reference to System.Data.Linq in project A ensures that it uses project B methods instead of directly accessign System.Data.Linq methods, which I want to avoid.
View 3 Replies
Aug 26, 2010
I have a solution with two projects within:
Company.Project.vbproj
Company.Project.Tests.vbproj
Within the Company.Project.vbproj assembly, I have a class FriendClass.vb which scope is Friend (internal in C#).Now I wish to test this FriendClass.vb from within the Company.Project.Tests.vbproj assembly. I know about the InternalsVisibleToAttribute, but that is not an option in Visual Basic .NET 2.0, as it is only available with C#, in .NET 2.0 (see here).I would like to create myself a proxy class using this internal FriendClass from within my testing assembly, so that I could instantiate it and do the testings accordingly.
View 1 Replies
Oct 20, 2010
When I try to compile my VSTO Outlook addin, I get this error:
Reference to class 'RibbonBase' is not allowed when its assembly is linked using No-PIA mode
View 2 Replies
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
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
Mar 22, 2012
I am coding a program that will allow the user to input 5 payrolls for Store 1, Store 2, and Store 3. The total of the 5 payrolls are then added together and shown in the respective Store's labels. A total label is also there to add up all the totals into one number. The numbers in the label must be in currency form. My problem is the numbers don't add correctly when I hit calculate. The first two numbers add together, but then after that the number just seems to subtract a random amount.
So far I have this --
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
[CODE[...
View 14 Replies
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
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
Dec 25, 2011
Class1:
Dim v as integer
public sub storeVar(byval s as integer)
v = s
end sub
[code].....
I need to save a reference of variable s in Class2 in variable v in Class1.(i.e. when the value of s changes v also changes (and vice versa)Is this possible since vb.net doesn't have pointers?Will it work if I change "byval" to "byref"?
View 1 Replies
Jan 18, 2010
I have an Object(Class) that consists of a few List Of(T)'s where T is other classes that can be defined by reading lines of a CSV file.I could (I imagine) do the same thing with XML.My question is when does one choose between the two.Are there cases where one is preferred over the other for data storage?
View 3 Replies
Jan 17, 2011
I have an application that I'm writing and I'm trying to declare two variables from my sql server, store the values and pass them to my forms.[code]...
View 5 Replies
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
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
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