VS 2010 Use Variable From One Sub In Another?

May 29, 2011

So I have an arraylist with some strings in it in one private sub. But I would like to use this same arraylist in a different private sub also. How could I accomplish this?

I tried changing the subs to public but still got the "is not declared" error. And I tried switching the arraylist's dim with public only to get another error.

View 7 Replies


ADVERTISEMENT

VS 2010 Compiler Creates New Variable Automatically When Use If Statement Without Strictly Declared Variable?

Jan 10, 2011

Say that i have the following code that parse about 20k records from the DB.

Code #1

vb.net While reader.Read()
list.Add(If(Integer.TryParse(reader(0).ToString, 0), Integer.Parse(reader(0).ToString), 0))
End While

And then another code which does the very same thing but it seems to be a little cleaner.

Code #2

vb.net While reader.Read()
Dim storeowner As Integer = 0
Integer.TryParse(reader(0).ToString, storeowner)
list.Add(storeowner)
End While

This is what i am confused about; does the compiler creates a new variable automatically when i use the if statement without strictly declared variable? What approach is better in sense of performance?

View 2 Replies

VS 2010 Merging An Integer Variable With A String Variable?

Jun 2, 2011

Say I have something like this

Dim Level1 as Integer = 83
Dim Goal as String
Goal = InputBox(" What level is your goal?")

[code].....

View 7 Replies

VS 2010 Variable Name Within A Variable?

May 18, 2012

If a string variable contains the name of an integer variable how do I then use the contents of the integer variable.i.e.I have a string variable called 'Rowname' which will contain the name of an integer variable.The integer variables will have been previously defined with values such as RowA = 0, RowB = 5, RowC = 10..I now want to add together the contents of the variable defined in 'RowName' with a the contents of an integer variable ColumnNumber.

View 7 Replies

VS 2010 Variable Increment On Vb 2010

Jan 17, 2012

i want to create a program that pressing a button will increment an integer variable and a textbox will show the result. Te code i wrote is below:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim i as integer
i = i+1
textbox1.text = i
End Sub

now, the same code works for the vb6 form but on vb 2010 the textbox just show 1 and does not increment any further.

View 3 Replies

VS 2008 Error: Range Variable 'sender' Hides A Variable In An Enclosing Block Or A Range Variable Previously Defined In The Query Expression

Mar 25, 2010

I 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.

View 2 Replies

.Net And VS 2010 Append A Variable To An URL?

Apr 16, 2012

I'm a newbie writing my first app. I need help with the following: I need to retrieve the logged in user which = GID, I then need to append it to a URL which will start our Help Desk chat client. I can retrieve the GID easy enough but can't figure out how to append it and pass it with the URL. I found a post which instructed to declare the url as a string also and concatenate it. The UserName would follow the ":" at the end of the Url.

[Code]...

We use javascript to do this from the HelpDesk site, but I need to adapt it to work from my app.

View 1 Replies

VB 2010 :: A Variable With A Value Of A Label Name?

Nov 4, 2011

I'm using VB 2010 Express and have a label named "lblTitle" in my form.The next code doesn't work and I know it , but how can I do something like this?

Dim bla As String
bla = "lblTitle"
bla.Text = "Hello world"

[code].....

View 5 Replies

VS 2010 Form Name In Variable?

Sep 23, 2010

I have an apllication with many many distinct forms.

So, I need sometimes open a form, wich the name is strored in one variable

For example I have this:

dim aaa as string
aaa="frmTestForm"
I wanna open the form who have the name keepted in aaa.
Something like this:
[aaa].show()

View 7 Replies

VS 2010 Get Handle Of Variable?

Aug 28, 2010

I need to get the handle of a variable. How do I do this?

DEVICE_PARAMETERS = New PresentParameters
ZeroMemory(>>Handle of DEVICE_PARAMETERS<<, Marshal.SizeOf(DEVICE_PARAMETERS))
-Ren�

View 4 Replies

VS 2010 How To Enter Value Of Variable

Mar 10, 2012

I have the following line of code which keeps giving an error.[code]I know what is causing the error, it is the ItemCount which remains as ItemCount in the command line not the value of ItemCount but I can't work out how to get the integer value.

View 4 Replies

VS 2010 There Is An Variable Containing The Sub Or Function Name

Jul 17, 2010

into a Sub or Function, there is an variable containing the Sub or Function name? Public Sub MyFunction..... subName = thisSubName obviously I can do subname= constant, but I want an semi-automatic way to log the running of several subs as CustomerDelete and so on. also in the validation events of input box's I want to do some kind of validation calling a function without constants, as result = validate(InputBoxName, InputBoxContent)

View 4 Replies

VS 2010 Using Variable In Different Classes?

Oct 21, 2010

Public Class Form1 Dim CharList As ArrayList Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click CharList.Add(TextBox1.Text.ToUpper)End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

[Code]...

View 2 Replies

VS 2010 Variable 'xxx' Is Used Before It Has Been Assigned A Value?

Aug 24, 2011

i am using the following VB6 code and I get this error Variable 'osv' is used before it has been assigned a value in VB2010.I want to use this code/method for getting the version, I just want to fix this

Public Class Form1
Private Declare Function GetVersionEx Lib "kernel32" Alias "GetVersionExA" _
(lpVersionInformation As OSVERSIONINFO) As Long
Private Structure OSVERSIONINFO
Dim OSVSize As Integer

[Code]...

View 2 Replies

VS 2010 Variable From Two Strings?

Oct 17, 2010

Public Class Form1
Public tc1 = Color.Blue
Public tc2 = Color.Green

[code].....

View 4 Replies

VS 2010 - Possible To Assign Variable To Infinity?

Apr 12, 2011

Is it possible to assign a pixel value of a binary file to infinity? Lets say that my binary file is composed of 4 pixels only and the values are (1, 4, 8, &)... Would it be possible to assign the fourth pixel to infinity?

View 7 Replies

VS 2010 - Send Variable To Sub On New Thread

Jun 12, 2011

I have created a class with a public sub which has a variable with it using byval:
Public Class clsMessenger
Public Sub Messenger(ByVal Port As Integer)
End Sub
End Class

I now need to start that sub in a new thread and pass a varible to it but I am not entirly sure how to go about that. At the moment I have:
Dim ClientConnection As New clsMessenger
Dim ClientThread As New Threading.Thread(AddressOf ClientConnection.Messenger)
ClientThread.Start()

I can't use a global variable because there is going to be multiple instances of this routine running on different threads and each time the variable to be passed will be different.

View 8 Replies

VS 2010 : Dynamically Dimension A Variable?

May 5, 2010

is it possible to dynamically dimension a variable?in my case, i have a chart that has a varying number of series on it depending on the data extracted and in order to use those series, i have to dimension them manually before adding points to them, IE:

Dim series1 as New Series()
Dim series2 as New Series()
etc
etc

my series data is contained in a datatable, so i'll know the count required, but it will change at runtime, so obviously doing something like this won't work, but explains what i'm trying to do:

dim recordcount as integer = datatable.rows.count
for i = 1 to recordcount
dim "series"+recordcount.tostring as new series()
next

View 13 Replies

VS 2010 : How To Make Variable Switches

Nov 30, 2009

i have a drop down box, with 2 Options Yes and No,what i want to do is

if questBox = Yes
do this
else if questBox = No
do that
end if

but not sure how to do it.

View 1 Replies

VS 2010 : How To Serialize TcpClient Variable

Mar 25, 2011

How to serialize TcpClient variable

View 7 Replies

VS 2010 : Variable 'retVal' Is Used Before It Has Been Assigned A Value

May 4, 2012

I get error "Variable 'retVal' is used before it has been assigned a value. A null reference exception could result at runtime." Here is my

Private Function JoinDomain() As Object
Dim BungeOU As String = "OU=Computers" & ",OU=" & SitesCmboBx.Text & "O=Na.Dir.Bunge.Com"
Dim args(4) As String
'Dim args2(2) As String

[code]....

View 6 Replies

VS 2010 Convert String To Variable

May 28, 2012

[Code]...

Now I'm wondering if it is possible to convert text to one variable defined up i.e.: dim mycolor as string

[Code]...

Is it possible to convert string mycolor to Color variable as defined before?

View 4 Replies

VS 2010 How To 'sort' A List Variable

Feb 19, 2011

I have this

Public strDBData As New List(Of SearchDatabases)
Public Structure SearchDatabases
Public strName as String

[code].....

If you need to know what i'm doing this it it:I'm parsing a webpage that lists information such as; Name, Site URL, How many members etc.And thats fine, but i want to put the names in a listbox, and then when the user clicks a name in the listbox it displays the other data about that name such as the site URL and how many members they have.This is easy to do but i have made my listbox sorted so the names display alphabetically, so then my strDBData index's don't line up correctly, to fix this i need to sort the

View 6 Replies

VS 2010 Pass Global Variable In DLL?

Aug 16, 2011

How can I pass the global variable to .dll from windows application (.exe)

Test.dll 1. FunTest1 (Parameter Required)
------- 2. FunTest2 (Parameter Required)

Within 'FunTest2' it call 'FunTest1'.

And in .Exe I call 'FunTest2' and want to pass the parameter for 'FunTest1' also.

View 1 Replies

VS 2010 Pass Variable Into SQL Query?

Apr 18, 2011

My goal is to make the content of TextBox1 to depend on the value chosen in ComboBox1. My code is as follows:

Imports System.Collections
Imports System.Data
Imports System.Data.OleDb

[Code].....

View 5 Replies

VB 2010 Way To Pass A Variable Back And Forth Between 2 Forms?

Apr 13, 2011

What's the simplest way to pass a variable back and forth between 2 forms?Let's say I have form1 and form2. Form2 has textbox2 and button2. When button2 is pressed I need the text in textbox2 to display in textbox1 on form1.

View 4 Replies

VS 2010 - Executing Operation Using Operator From Variable?

Feb 2, 2012

Let's say we have the following
Dim number1 as double = 2.24
Dim number2 as double = 12
Dim symbol as string = "-" (or "+" or "*" or "/")
How is it possible to execute this operation using the operator from the variable?

View 3 Replies

VS 2010 - QUERY The Information From The Databse With Variable

Dec 9, 2011

I am almost finished my project for a vb database app, but lack the apparent knowledge to make this last connection. My listbox populates fine on form_load. I have identified the "category id number" from the database as the identifier for my information to be displayed (from that field). The variable catID returns the proper "category id" number to match the information to be returned when clicked (a description is part of the field for the appropriate number)

I presume the extra sub procedure I wrote for another daCategory = New OleDbDataAdapter is probably not necessary, but I'm very confused. How do i QUERY the information from the database with variable catID? tblSamples.Category(#) to return tblSamples.description to textbox when called from the listbox. I am not/will not use a databinding approach. [Code]

View 1 Replies

VS 2010 - Storing Data In Some Type Of Variable

Jan 19, 2012

I have data that I want to store in some type of variable where I can easily access when needed. For example I have:
google.com -> This is a cool website.
yahoo.com -> News website
gmail.com -> Mail website

I want to be able to store those in some type of group so if I go like:
get data of google.com without going through a loop.

View 2 Replies

VS 2010 : Insert A <br> & </br> For A New Line Within A String Variable?

Nov 28, 2011

I am developing an app which allows a user to send emails.I am using a multiline text box for the user to capture data, but when I convert it to a string it does not pick up a new paragraph.How would I insert a <br> & </br> for a new line within a string variable?

View 6 Replies







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