Use The Number In One Variable To Access A Set Of Different Variables?

Aug 10, 2009

I have a variable called VarNUM which stores a number from 1 to 10. What i want to do with this is based on the current number stored in that variable call a different set of variables from a module with Public Structure ITEM1. It has the same set of variables for ITEM1 - ITEM10 but with different values. So ya in raps how can i use the number in one variable to access a set of different variables? Something like ITEM(VarNUM) then the set of variables that all have same name but with different values so that i dont have to go,

Code:
if VarNUM = "1" then
name = ITEM1.name
store = ITEM1.store

[code]....

View 10 Replies


ADVERTISEMENT

Variable Naming Conventions To Illustrate Variable Type And Where Variables Are Declared

Aug 24, 2009

I am looking for a good resource on variable naming conventions to illustrate variable type and where variables are declared. So I will have public variables, Private variables, private or local variables. I also may want to declare variables with the same name in different class code (i.e. in the code behind different forms). I am assuming good coding would dicatate a prefix for declaration location.

View 4 Replies

Greater Number Among Number Stored In A Set Of Variables

Nov 10, 2010

I have 10 number in a set a variables. (say: 25, 33, 11, 4, 3. I want to get the biggest number in a message. How do I get it?

View 2 Replies

Set Variable Names With Variables

Apr 29, 2009

I am looping through a collection of items. Within that loop I need to set variables but they need to be a variable. I tried using lists but for some reason they don't get set properly. Heres what I have so far...

[Code]...

View 1 Replies

Creating Variable Names From Other Variables?

May 20, 2010

how do I DIM a variable's name using previously declared string varialbes? I have been using PERL for processing data stored in text files but I now have a business need to use VB2008. I would like to do something like this:

dim name1 as string = "ABCD"
dim name2 as string = "123"

'here is the part that I don't know how to do - create a 3rd variable name concatenated from name1 and name2:

dim string.concat({name1,name2}), or maybe use a counter in a line like 'dim namex as string' with x being a counter value.

Essentially I want to dim variables using text strings extracted from a file. In PERL I have declared literals and arrays, such as 'my @$name1', which creates an array named with the contents of $name1. In VB2008 I am not sure how to make this work with the DIM statement.

View 5 Replies

Access A Database (SQL) And Have Access To The Data Set As Variables?

Sep 18, 2009

I need a good book for beginning to use VB 2008. I have some (limited) experience in using VBA. I want to access a database (SQL) and have access to the data set as variables?

View 6 Replies

Asp.net - Number Of Variables Pass To Function?

Dec 5, 2011

if this is a dumb question. I don't ever have to write anything in VB.NET.But I am passing variables named "name" to a function and sometimes it may be 1 name or 2 names, etc. I want to check in the function if its only 1 name don't add a comma, if it's 2 names add a comma. Is there a way to get how many "names" there are?

EDIT: Added my ode to make my question a little more clear. sorry for not doing it before.

My Code:Public Function GenerateCSV(byval str as string, byval str1 as string, byval str2 as string, byval GrpName as string)

[Code]...

View 4 Replies

Maximum Number Of Controls And Variables?

Jan 13, 2009

how many variables and controls (i.e. text box, listview, buttons, etc) can a VB program has without slowing down its performance?

View 2 Replies

Add A Variable That Shows Amount Of Tax Deducted In A List Box Among Other Output Variables?

Nov 27, 2010

Im trying to add a variable that shows amount of tax deducted in a list box among other output variables. If anyone can help I would like to know how to code the lstResults.Items.Add("-$ " & Tax & " Tax") bracket to display the amount of tax deducted from the total salary wages.

Public Class Form1
'Decalirs Variables
Dim Hours As Integer
Dim Overtime As Integer

[code]....

View 3 Replies

Local Variables In Shared Method Work Like Static Variable In C?

Aug 23, 2011

Will the list in this shared method keep its state throughout the life of the method? Or will a new list be created every time this method is called?

[Code]...

View 3 Replies

Inter-Program Variables - If A Variable In Form1 Is "True" Than, How Can Make A Variable In Form2 Turns To "True" Too?

Feb 11, 2012

I know that

Public Incognito As Boolean

is a variable called "Incognito" that is class-wide that is a boolean.My question is that is there a form-wide variable form that can like communicate with different forms. So if a variable in form1 is "True" than, how can you make a variable in form2 turns to "True" too?

View 1 Replies

VB 2008 Why Are Static Variables Set Equal To 0 In The Declaration When 0 Would Be The Default Value Of The Numeric Variable

Apr 21, 2010

Why are static variables set equal to 0 in the declaration when 0 would be the default value of the numeric variable anyway when it's first declared? Not including the "=0" in the static declaration seems to work with no problem.

View 2 Replies

Private Read/Write Access And Public Readonly Access For Variable In Class?

Jan 12, 2012

Is it possible to set a variable in my custom class for Private Read/Write access and Public Readonly access without creating Properties with Get and Set? In other words, from within my class I want full access and from my form I only want read access. Right now I declare my variable as either Private or Public to control Public read/write access. I tried googling my question a bit but I'm not sure what the correct terms even ar

View 5 Replies

Access Variables From Outside Of A Loop

Sep 15, 2010

I'm trying to use variables created within a loop, but I'm not sure how to do this. I've searched around on the net and there is a few recommendations to try and put what I require into a function then just call the function.

[Code]...

View 2 Replies

Can Access Variables That Don't Exist Yet

Feb 1, 2012

Basically I just want to use

tile1.backcolor = colors.while (just an example)

however tile1 is only created WHEN the form loads, and it will not let me compile it becuase it's saying it doesn't exist

View 8 Replies

How To Access Variables/arrays

Dec 14, 2011

Public Sub drawChart()
Dim panel As Graphics = picBox.CreateGraphics
Dim myTextBrush As SolidBrush = New SolidBrush(Color.Black)

[code].....

View 1 Replies

Access Shared Variables Of A Class?

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

Access Variables Inside Sub1?

May 25, 2010

i Have two subs

Protected Sub Btn_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim Id as string = MyClass.getID
Private Sub Sub2(ByVal doc As Document)

' in here i need to access the ID from the above sub the Id needs to be in the btn_click sub cos it reates a unike id every time it is clicked.I am trying to capture the id at the time the button is clicked and store it on a variable.

View 3 Replies

Cant Access Public Variables From Another Form?

Aug 25, 2010

I have a string on my main form called String1. When I open another form, I need access to this value. In the form I open, I have always done something like:Dim NewString as String = Main.String1

This has worked in the past. Well, I ended up renaming my forms (from Form1 to Main) in the property window and it now when I type the above code, it does not list Main as a form. Nothing that I renamed seems to exist now.

View 2 Replies

How To Access Variables From URLs That Come From Get Method

Mar 14, 2009

Asp.net has turned out to be alot easier to use than PHP (so far). However, I have been searching for a while and simply cannot figure this out. How do I get the variables that are contained in the url of my page (that originate from a form that had the method "GET") and utilize them? For example, my page would be [URL]. How would I get the value of some variable?

View 5 Replies

How To Access Variables In Another Class Without Deleting Any

Oct 31, 2011

I have been charged with porting a VB6 project into VB.NET. In vb6, if you were in a class separate to a particular variable, you could access that variable easily:

Public Class Foo
Public k As Integer
End Class
Public Class Bar
k = 12
End Class

In VB.NET, my understanding is that before you can use a variable in another class, you must declare a new instance of it:
Dim foobar As New Foo
This would be fine, but I have to access these variables from different classes and every time I declare a new instance, it wipes all old values from the variables, which I need. I tried using Inherits statements but they presented many problems.

View 2 Replies

Expand The Number 2 Like A Variable From 2 To 4.5?

Mar 6, 2010

i have this variable Dim odddivider2 As Integer = CInt(20 6) and i want to expand the number 2 like a variable from 2 to 4.5 how i have to make that

View 14 Replies

Assigning Access Fields To Variables Or Textbox?

Jun 20, 2011

I'm facing a problem with my current member card reader development.

I'm reading the card number (just a serial number of 4 digits) with a card reader. this seems to work fine (even converting the text string to integers).

This number is then put in a query to find the exact record that corresponds with this number

Me.JSM_LedenTableAdapter.GetDataByKaartnummer(IntCardNr)

View 4 Replies

Querying/Displaying Boolean Variables From MS Access?

Jan 14, 2011

I am querying the MS Access Database to display the results in a datagridview. This is my

Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data.mdb"
Dim SQLString As String = "SELECT * FROM Groups where Selected = Yes"
Dim OleDBConn1 As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(ConnString)

[code]....

The variable Selected from the query statement ("SELECT * FROM Groups where Selected = Yes") is a Boolean in the MS Access Database. However, this statement returns empty result even though most of the values for Selected are Yes. In the access database however, if I enter a 'Yes' for the value of Selected, it shows up as -1 and 'No' shows up as 0. So I even tried changing the query statement to ("SELECT * FROM Groups where Selected = -1") and also ("SELECT * FROM Groups where Selected = 'Yes'") but none of them work. Can you please help me fixing this query because I can't change the database?Also if I change the query statement to ("SELECT * FROM Groups"), then all the data shows in the datagridview, however, the values for Selected column do not display. Instead I see check boxes and I can't click them. How can I display the values correctly?

View 8 Replies

String Variables From Random Access File

Nov 17, 2010

I'm tasked with the job of creating a javascript version of a units conversion application written in vb6. I have the source code but I don't have vb 6. The source code uses a dat file to hold a conversion array (unit type, unit, xfactor, plusfactor). Getting the data out of this file would be good to me. I tried creating a little app in vb 2010 to write the data from that dat file to a txt file using essentially the same code as the source code. And that has been somewhat successful (took a while to figure out the fixed string business). Now I can pull the data out as an array. The math elements of this array look fine but the strings are somewhat read-able but too garbled to use. I can't seem to fix that by changing the character set/encoding.

View 3 Replies

Accept A Variable Number Of Parameters?

May 26, 2009

I am trying to design a Function/Sub that will need to accept a variable number of parameters. Catch is that the parameters being passed are arrays themselves. As i understand it when you pass a variable number of arguments to a method, you pass them via an array. What im looking for is to make a method that would accept this form:

[Code]...

View 6 Replies

Can Combine V & And Number To Manipulate Variable

Jun 9, 2011

I have 10 variables that have numbers at the end in sequential order (e.g. V1, V2, V3, ect.). I would like to perform a function to find what the position is in an array and then add then add the value to the correct variable. Can I combine V & and the number to manipulate the variable?

View 2 Replies

Console Random Number To Variable?

Nov 8, 2009

I am making a simple console game. If you have ever heard of the board game code breaker you will understand better.

In my version of the game you will have to figure out a four number combination. The only numbers it can be is 1, 2, 3, or 4.

I need to generate four random numbers and put each on into its own variable. This allows me to call back each number.

How do I do this? I have been doing some research on random numbers and I use this code to generate four random numbers

Dim rnd As New Random()
Console.WriteLine("20 random integers from -100 to 100:")
For ctr As Integer = 1 To 20
Console.Write("{0,6}", rnd.Next(-100, 101))
If ctr Mod 5 = 0 Then Console.WriteLine()
Next
Console.WriteLine()

But I can't figure out to put each number into a variable so I can call the same numbers back.

View 9 Replies

Double A Number For Every Time A Variable Is Used?

Sep 18, 2011

If i have a variable '12'

and a variable 'hello'

how can i double the '12' each time the variable is used?

What im trying to do is have a textbox which the user writes in a number, the number they enter then determines the amount of times a variable is written in a textbox.

so if the user were to put '3' into the textbox and click go, it would print hello12hello12hello12, how can i increase the number 12?

what i want it to do is look like this when the user presses go: hello12hello24hello36

View 1 Replies

Get A Variable's Value Set To The Number Of Data Fields?

Oct 16, 2011

How can I get a Variable's value set to the number of Data Fields in my DataBase that is NOT Nul.

I have in a table 10 fields or columns Named: Ing1, Ing2, Ing3, Ing4, Ing5, Ing6, Ing7, Ing8, Ing9 and Ing10. This fields will all most never all be fild, will be fild from 1 upwords. I need to know how many of them is NOT Nul.

View 5 Replies







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