Class Variable Assignments - Passing Values From S1 To S2
May 31, 2011
I am trying to work with classes and variables and don't seem to understand some behavior that is going on.
first off the class
Public Class csSession
Public ID As Integer
Public Name As String
End Class
Usage and behavior (example code)
Dim S1 as new csSession
Dim S2 as new csSession
S1.ID = 1
S1.Name = "1st Session"
S2 = S1
S2.ID = 99
When I assign S2 = S1 all the values of S1 passes to S2 but also there is a "link" or bond between the two variables now. If I change the values of S2 this automatically changes the values of S1!! Why does this happen and how can I prevent it? I just want to pass the variables values contained S1 to S2.
View 12 Replies
ADVERTISEMENT
Jan 14, 2011
I am trying to pass some declared variables to a stored procedure. Here is my
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startpayrollButton.Click
Dim ssql As String = "select MAX(payrolldate) AS [payrolldate], " & _
[Code].....
View 10 Replies
Sep 16, 2011
I'm running VB2008 on Windows 7; I've written out a ver simple piece of code:
Option
Explicit
On
Module
[code]....
When I run or debug the code, it asks for the First Number and then just completes the running of the program without asking for the second number and uses some random number. The console.readline() doesn't work either, the console window just disappears.
View 2 Replies
Jun 2, 2010
I'm tyring to pass a variable data type to a template class. Something like this:
frmExample = New LookupForm(Of Models.MyClass) 'Works fine
Dim SelectedType As Type = InstanceOfMyClass.GetType() 'Works fine
frmExample = New LookupForm(Of SelectedType) 'Ba-bow!
frmExample = New LookupForm(Of InstanceOfMyClass.GetType()) 'Ba-bow!
[Code].....
I'm assuming it's something to do with the template being processed at compile time but even if I'm off the mark there, it wouldn't solve my problem anyway. I can't find any relevant information on using Reflection to instance template classes either.
(How) can I create an instance of a dynamically typed repository at runtime?
View 4 Replies
Feb 1, 2011
I am working on a project where my class has to execute VB code provided by the user, to make it simple I am trying to recreate my own eval function, I am using the following code I found on the web to do this task.
Imports Microsoft.VisualBasic
Imports System
Imports System.Text
Imports System.CodeDom.Compiler
Imports System.Reflection
[Code] .....
The problem with code is that it can't access any variables or there values, so I have decided to get the variable names, there values types and there types dynamically and recreate them in the class that is being created dynamically. Any way to get the variable names there types and values in the current class or method, so that I can recreate them, and execute the user passed code, the user knows what variables are in the current class or method and there datatypes but he don't know there values as they may have changed, so he can't initialize them. Is there a way to do this, this code will be called in an asp.net page on page_load event, the code passed by the user is stored in the variable vbCode that is passed as a parameter.
View 2 Replies
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
Apr 7, 2010
I'm sure there are several ways of achieving my goal but I am after opinions on what you think is the best option. I'm writing a vb.net application which (amongst other thinks) interfaces with media players in the home. Because there are different types of media playersI'm trying to structure it so each type of media player has it's own class which interfaces to a management class which sits on top of all the different devices types.
The device classes are responsible for discovering the phsyical devices and returning that information up to the management class. A device class may be responsible for monitoring 1 or more physical devices so..
[Code]...
View 1 Replies
Apr 28, 2009
I seem to have problem with passing a collection/sorted list/ list of strings from one class to another.I am using property procedure to pass it, however nothing is sent to another class. There isn't any error messages either.[code]
View 3 Replies
Dec 14, 2011
I am using a function that is provided by the maker of an IO device that I'm using and the call for this device turns on and off the 16 ports on the IO device by sending the value true or false to the board. The call is as follows:
[Code]...
View 12 Replies
Oct 13, 2009
here's the snippet of my code that im trying to solve since last week...
icePayment.aspx If (Left(Request.Form("return_url"), 7) <> "http://") Then
errorInput = errorInput & "Invalid return URL path! <BR>" errorExist = True
Response.Redirect("InvalidUrlError.aspx")
Else
[Code]...
View 2 Replies
Jun 3, 2011
I'm a Quite new to Visual Basic 2008. I have to build a database application for one of my assignments and one of the problems I'm having is to build a form that will be used to search a customer from a Customers table. The database is from access2007.
I have to have 4 radio buttons on the form which will be the options to search the customer by, so I can search by Customer ID, Customer Name, City and postcode. When I select one of those options I need to enter the phrase I'm looking for within a text box I have called TextBoxSearch then press a command button to perform that search but I'm not sure how to do this.
The customer ID is the 1st row, Customer name is the 3rd row, City is the 4th row and the postcode is the 5th row. How do i tell the program to go to that row and grab the detials based on the text entered from the text box? and display only those detials on the datagrid view?
View 1 Replies
Mar 1, 2011
Take a look at this VB.NET code:
list = GeoController.RegionByCountry(country, language)
Region.allByLanguage(key) = list
In C#, I could write this in one line:
[code].....
View 3 Replies
Sep 26, 2011
i had a class called Tag with a structure like:
public class Tag
private _members
public properties
public shared database_methods
end class
this class was tailored for mysql database. i'm currently adding access 2007 support so i split tag into tag and tagdata with structures like:
[Code]...
View 2 Replies
Aug 18, 2011
I have a variable that gets a value in a js function. I need to get its value as a double into a vb.net variable. I have tried putting the variable into a label then grabbing it from the label in vb.net as shown in the code below:
[Code]...
View 3 Replies
Feb 18, 2010
Dim SecondName As String = SecondNameTxtBox.text()Is the above statement a correct one?Here I want to assign the value of the text box into tat "SecondName".If it's wrong, please tell me the correct way to write this statement.
View 1 Replies
Nov 15, 2011
how to pass value from database to a variable.
This is my query:
Dim it As String = "Mouse"
Dim itNo As String
SELECT * FROM tblITEquipmentName WHERE equipmentName LIKE '" & it & "%'"
I would like to get the ItEquipmentNo and pass it to variable itNo
View 7 Replies
Jun 15, 2010
i have 2 forms -> form 1 and form 2
in form 1 -> 1 button
in form 2 -> 1 textbox and 1 button
when I click button in form 1, it will show the form 2..how can i pass the variable (data from textbox in form 2) into a variable in form 1 after clicking the button in form 2 ?
View 8 Replies
May 22, 2012
this is the linkbutton
<asp:LinkButton runat="server" ID="linkId" OnClick="doSomething(10)">ID
</asp:LinkButton>
and this is my sub
[code].....
View 2 Replies
Jan 15, 2010
I know in VBA you could pass an entire form as a varible. Since using global variables are not advised in .net 2008, is there anyway to do this ?
View 9 Replies
Nov 23, 2011
Not sure how to do this sub that passes a variable that is used in a Dim.
fill_in_field("main_form.WebBrowser1")
Sub fill_in_field(ByRef WebBrowser As String)
Dim ElementCollection1 As HtmlElementCollection = WebBrowser.Document.GetElementsByTagName("input")
End Sub
Dim ElementCollection1 As HtmlElementCollection = WebBrowser & "Document.GetElementsByTagName("input")"
This is what I would like.
Dim ElementCollection1 As HtmlElementCollection = main_form.WebBrowser1.Document.GetElementsByTagName("input")
View 2 Replies
Sep 18, 2010
It's been a long time since I have been on this forum. I have been incredibly busy lately, anyway, does any one knows how to use the "Ctrl+Alt+]" to align assignements in VB.Net 2010. It is a part of the "Productivity Power Tools" from Microsoft. I cannot get it to work even though I can see that the keys are assigned to it.
View 6 Replies
May 8, 2012
Create a class named Service. Inside the Service class, declare a class variable named Started. The datatype of this variable is Boolean.Public Class Service Dim started as Boolean End Class Create a class named Server. Inside the Server class, declare a dynamic array that can contain elements of the type Service.(Note: For convenience, both the array and the variable Started can be accessible from a client program that creates an instance of Server and Service respectively)
Create a constructor for the Service class. When the constructor is executed, it will set the value of the class variable Started to True. Create two new classes: WebServer and DatabaseEngine. Both of these classes inherit from the class Service. Inside the Service class, declare a Sub procedure (method) named Terminate. This method should display the following text Service stopping in a message box when executed.This method can be overridden in classes that inherit from Service class.
Inside both the WebServer and DatabaseEngine class, override the method Terminate inherited from their base class Service. Both methods should first call the base class Terminate method. The messages Web server stopping and Database engine stopping should also be displayed in a message box when the Terminate method for the WebServer and DatabaseEngine are called respectively. These messages should only be displayed if the Started variable inherited from their base class is not equal to False.
Inside the Server class, declare a method named Shutdown. This method does not return any value. When executed, it will call the Terminate method for each of the Service instances (if any) in the arrServices
array. You should call the Terminate method within a For Each loop that loops through the elements of the arrServices array.
In the Sub Main method, create an instance of the class Server. Set the size of the arrServices array in
your Server instance to contain 2 elements. Create first a WebServer instance and then a DatabaseEngine
instance into this array. Call the Shutdown method from your Server instance.
View 7 Replies
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
May 18, 2012
is there a way i can do like this in vb.net
[Code]...
what i want is that idx keeps incrementing after each line, without incrementing it on a seperate line.
View 1 Replies
Jul 6, 2009
I want to know if it's possible to retrieve the variables name from when it was passed into a certain function. For example, if I call parseId(myId) to a function with the signature parseId(id), i can obviously retrieve the value of 'id'. However, is there any way I can retrieve 'myId' as a string (without passing it as another value)? Specifically in vb.net, but I'm interested in how it would work in any given language.
View 3 Replies
Nov 15, 2010
I have a public variable that I declared in form1 of an application. I am trying to call that variable in form2 and then pass that variable in a sql query. If I declare:
Public Class Form1
Public payPeriodStartDate, payPeriodEndDate As Date
How then to I declare that variable in form2 and how to I pass it to my sql query.
Here is the code I have for form1: [Code]
and when I debug this form, no data will appear. I'm sure that it's something wrong with how I'm either calling the variable in form2 or in the query. Can anyone offer any assistance on this?
View 9 Replies
Apr 26, 2011
I have 2 dropdownlists, one is State and the second is City. I am trying to create it so, when a user clicks the State, the second dropdownlist is populated with City names from a datatable.[code]
View 3 Replies
Oct 20, 2009
passing a variable to a sub procedure by reference. Not sure I understand how it works. Here is the code.
Private Sub bntcompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntcompute.Click
Dim x, y As Double
getnumbers(x, y)
displaysum(x, y)
[code]....
Is the newly modified variable actually being Passed back? and If so where in the statement is it passed back. is it being passed back to the call getnumbers or is it passed back to the statement displaysum?
View 6 Replies
Nov 29, 2011
I'm using MVC2 with jquery.I'm trying to open a partial view in a jquery Dialog container, passing an itemID of an object to be deleted.What I'm doing to accomplish this is passing in an action that renders a view to jquery, which I can get to work without variables.f I try to pass in the ID of the object to be deleted, the action doesn't even trigger.
Here's my jquery code:
$(function () {
var itemToDelete
[code].....
View 1 Replies
Feb 18, 2010
Doing a small project where I would like to be able to print the results of certain calculations. I want to open a new form where the data can be neatly presented and printed. I just can't seem to make the data get passed along to the new form when I open it..
[Code]...
View 2 Replies