How To Create And Use A Variable
Jun 30, 2010Can someone please help me learn how to create a variable and property and use it?
View 5 RepliesCan 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.
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".
Okay, Im a newbie to VB, so how do you create a Global variable inside a sub.
View 6 RepliesI 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."
How 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 RepliesI'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]...
I have a stored procedure that requires a DATETIME variable to display the results in crystal reports. How would I create an input text box and pass the variable to the procedure? Is it even possible to program in vb or C# in crystal reports, or do I need visual studio 2008?
View 1 RepliesLike in topic.I want adddashes to variable.So textbox1.text = "Nice "weather" is..."BUT it's not working :/ when I'm using dashes VB 2010 thinks that I want close
View 6 RepliesHow could I create declaration(event) to a variable control in VB .net ? [code]please i need to know how to insert this (declaration) newweb_ DocumentCompleted it's similar to WebBrowser_DocumentCompleted but it's a variable
View 5 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 am trying to create new variables inside a class after creating its object at runtime. The problem is that I don't know the variable names or the value beforehand so I have to create the new variables at runtime.
[Code]...
This is a more elaborate explanation of my code. If you observe that in the Eval function I have tried to evaluate Fval(abc). Now the object array abc is not declared in the Test class because it existence is not known beforehand. What I want to do is create an object array abc of length 2 and populate it with some values and when Fval(abc) is called then then the value of index 1 should be the return value of Eval fucntion.
How does the GC dispose objects created in the following 2 scenarios?
1)
Private Function DoSomething() As Boolean
Return New DatabaseManager().Insert()
End Function
2)
Private Function DoSomething() As Boolean
Dim mngr As New DatabaseManager()
Return mngr.Insert()
End Function
In Option 1, I don't create local variable to hold the reference of the object. In Option 2, I hold the reference in local variable.What option is better and why? (if any)
In my programming task I've gone down a dark alley and wished I hadn't, but there is no turning back now.
I'm building up a SQL statement where the table name, column name and id value are retrieved from query string parameters i.e. ("SELECT [{0}] FROM [{1}] WHERE [Id] = {2};", c, t, id)
But it isn't as bad as it looks, I'm protected: Only authenticated users (i.e. signed in users) can execute the Page_Load I'm checking that both the table and the column exists beforehand (using GetSchema etc.)I'm checking that the Id is an integer beforehand All my tables have Id columns The database connection is reasonably secure
[Code]...
OK, after trying to get this working for a couple of days now I decided that I would turn to the experts here. I am trying to create a nested loop with a variable amount of nests. Let me elaborate. I have a program that first asks for the minimum and maximum amount of loops, I currently have a SELECT CASE statement that addresses each level of nesting individually.
Dim cMin As Integer = InputBox("Min")
Dim cMax As Integer = InputBox("Max")
Dim c1, c2, c3 As Integer
[Code].....
Can you create a string variable, that has 3 prespecified acceptable values?I need a variable that you can basically set it to one of three values and nothing else. Basically so you can't fat finger setting the variable in code.
View 1 RepliesI wish to display a greeting to the user when they start an application. It's very simple "Good Morning John" or "Good Afternoon John" or "Good Evening John" depending on the time of day. How do create a time variable where it's based on 24 and not 12?
View 3 Repliesi 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.
I receive the error -
[Code]...