VS 2008 Create A Byref Variable?
Jul 16, 2009How would I create a variable and assign it to another variable and when I change one variable it will be changing the other also?
View 3 RepliesHow would I create a variable and assign it to another variable and when I change one variable it will be changing the other also?
View 3 RepliesJust wondering if it's possible to store a reference to an object in a variable.
I will elaborate:
[Code]...
I would like a label to always show the current value of a boolean. This will change a lot of times and would like the label to ALWAYS reflect this.
Is there some kind of way to have the label set to the boolean byref (so its always the same). Currently I'm assigning the label.text = boolean onLoad, so if the boolean changes after that its not reflected.
I have a subroutine that passes several variables to the called subroutine.I want one of the variables to be updated by the called subroutine and then check for the change in the calling subroutine. My code works fine except that the variable I am checking
calling Sub routine
Code:
Public Sub ProjectName_Exit(Cancel As Integer)
[code].....
Why if you pass an object as byVal into a method is it then treated as if it were byRef? I know you're only passing the reference across when you pass an object variable but why doesn't VB force you to decalre the header as byRef?
View 2 RepliesOkay, Im a newbie to VB, so how do you create a Global variable inside a sub.
View 6 RepliesI had a look through this forum and other forums but couldn't find what I was looking for. I am new to visual basic and have spent all day trying to find the solution to the following issue.I am creating objects from a class that store information about the user of the program. Each time a user signs up the program, I need the code to create a new instance of the class, creating an object and storing information about that user. The contents of this object will then be saved into a text file.
[Code]...
I have been working on this for a few days, and I am going around in circles. I can make the program work by including everything in the same sub procedure, but the assignment requires that I do certain tasks by using function procedures.What I need to do is take the contents of a text box, reverse the order of the first and last names, and add them to a list box. I can do that, just not by passing value from a function procedure. Here is my
View 4 Repliesis there any collection in vb.net which store object as byref and not byval.
View 4 RepliesI have a class OrderManager, that takes a parameter of type LocalFuturesList on construction. Now.. It doesn't seem to matter if I use ByRef or ByVal here.. It still references the parent class instance of it. It also doesn't seem to matter if I type New or omit it.. Probably also because it's just an address reference. But why is it like this? And what type of objects "acts" in this way? Further I find that if I change the object in the parent class by deserializing from a file (with my method call shown), then suddenly this reference is broken in some way, so the OrderManager instance now holds Nothing I believe.If my observations are correct I see two challenges:
1. How to pass a list NOT by reference?
2. How to maintain a list reference through deserialization? [code]
I have some code that is transforming the coordinates of a line.I want to keep the original coords and I thought passing the line ByVal would be the best way.The original VB6 code used a temporary variable so that the original coords were not updated.I'm confused as when the X & y coords of 'line' are changed 'MyLine' is also changed. I had assumed only 'line' would change and 'MyLine' would remain unchanged'.
Private Sub TransformSaveLine(ByVal MyLine As LineType)
Dim P As Integer
Dim line As LineType
Dim x As Double
[code].....
i am creating a quiz which would be 20 questions for software design students and may use alot of code.my first problem is the score for the test, i know a friend of mine can add up the score but he cant move onto the next thread until you have got the question correct which is sort of cheating, i want to know how you create a variable and make that variable stay in all the forms and add up the score of correct and incorrect answers and come up with a final score for the user in the end.
View 8 RepliesI am getting the error:"Range variable 'sender' hides a variable in an enclosing block or a range variable previously defined in the query expression."for this
Imports System.Data.SqlClient
Imports System.Linq
Public Class Form1
[code]....
I can select any other item from the table without the error. "sender" has the same properties as "receiver" in the SQL table.
Below I tried to do an Example:
[Code]...
Below is the called method: Friend Sub SplitOU2(ByVal inDN As String, ByRef OUDN As Object, ByRef Organisation As Object, ByRef VerksamhetTyp As Object) By doing this I can skip to declare the in this example "useless" variable Dim VerksamhetTyp as Object = "".
Can someone please help me learn how to create a variable and property and use it?
View 5 RepliesHow Can I create a Global Varibale for my vb.net project. When I LongIn I want to keep the user Id in a varible and I will Use it in deferent Forms. And The User name will be saver in the varible untill I close the Software.
View 1 RepliesI have a for next loop looping through a dataset.I want to create an instantce of a class for each row.How can I create another instance/variable for each row?
View 5 RepliesI am using VB to enter a 3 digit number eg 550 into strnumber then split this number into 5 using left(strnumber,1) and into 50 right(strnumber,2) I then want to set these two numbers a say x and y and use them to built and IP address this is where I get stuck...
View 3 RepliesI have some code like:
Lookup(Of String)("Testing")
Lookup(Of Integer)("Testing")
And both of those Lookups work great. What I'm trying to is call the appropriate LookUp based on the type of another variable. Something that would look like...
Lookup(Of GetType(MyStringVariable))("Testing")
I've tried to Google this but I'm having a hard time coming up with an appropriate search.
I am trying to use the value of one variable to call another variable of the same name.I have 2 variable one called VAR1 and VAR2.
The variable VAR1 has a value of "VAR2"
The variable VAR2 has a value of "HELP"
I want to be able to get the value VAR2 from the variable VAR1 I have defined the value of VAR2 early in the code and now I want to call that value by using the value of VAR1.The reason I am doing it this way as I have a list of 50 variables that are pulled from one system. Each of these variables have the same name as the columns of a spreadsheet. The total number of Variable stay the same but the total column headers may vary each time. I need to loop through each of the column headers match them with the variable names and add the data to the spreadsheet.
VAR1 = "VAR2"
VAR2 = "HELP"
i =1
[code]....
This is the tricky bit...if the value of the cell(1,i) = "VAR2" How do I get it to display the value of the variable of the same name In this case how will I get it to display "HELP" when I only have from the VAR1 value "VAR2" I know my code will bring back the value as a string but I want it to bring back that string as a variable and display the value of that variable?
How do I create a variable in Visual Basic?
View 4 RepliesWhere and how do i create a global variable for a combobox? I need to use it on different forms.
View 6 Repliesi am trying to create a table in a access 2007 database with the name stored in a variable wich the user inputs. For example, if the username entered by someone is "John", i want to create a table in the database also named "John". I have tryed this:
Dim mypath = Application.StartupPath & "\mydb.mdb"
Dim mypassword = ""
Di Cmd As OleDbCommand
[code].....
My app has a group of forms that do a specific work in different ways. I want to create a new variable of a form when I want with its name. So, I want a Function in this form :
Public Function GetNew (byref f as form ) as form
That give a form name and return a variable of that type. In other words, it must work as "dim f1 as new formx".
I can create event prodcedures for form objects, but is there a way to create an event that triggers when a certain variable equals a certain value?
View 3 RepliesDoes a variable create a memory cell, or is it actually the memory cell, for example: Dim Answer As DialogResult
This is the explanation I have written for that line of "This line of code uses a Dim (Dimension) statement to declare a variable called Answer.
This variable creates an object to store the users answer to a dialog result." and this is the explanation that my friend said it was:
"This line of code uses a Dim (Dimension) statement to declare a variable called DialogResult. This variable is a memory cell to store the users answer to the dialog result."
I'm trying to create a collection of variable binding in a class.It is intended to look something like this:
Dim x as integer, s as string
Dim c as new VBindClass
x = 1
s = "Hello"
[code]....
Is there some function that allow us to retrieve a unique ID for a given variable and also get/set based on variable?
Update:At last, I've managed to found the answer. Here's the code:
Dim gh As Runtime.InteropServices.GCHandle = Runtime.InteropServices.GCHandle.Alloc(obj)
Return Runtime.InteropServices.GCHandle.ToIntPtr(gh).ToInt64
how to create a global variable for this situation: I would like to store who logs in to a system (like, who is currently logged in, when he logged in) and then use that info for a transaction form, which will look like this: which admin made the transaction).
If I were to use a global variable, it would mean having to pass it onto several forms right (eg: from login form to the forms that will use the log information). I'm also thinking of just having a config file that will store the said login info that will be changed everytime a user logs in.
I have a query setup on the start form in my project - it looks for a user level (1 or 2 right now) I want to display/hide items on the form based on whether or not the user's permission (derived from this query) is a 1 or 2.
My question is, can i create a public variable out of this query to use on any form until the application is quit?
The query will be formatted something like this:
Dim
ssSQL As String = "SELECT UserLevel FROM [Employees] WHERE "
ssSQL &=
[Code].....
I've been looking at using PROPERTIES [URL] but frankly I don't understand it that well. Before I invest the time to read, understand, and truly comprehend this, I want to make sure it's the best way. My intended goal is to create my database connection string in a function/sub somewhere, then assign it to this project wide string variable, then I can use it in any form, project wide without having to recreate it.
[Code]...