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


ADVERTISEMENT

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

C# - Decompiling .Net Assembly Produces Code With Invalid Member Variable Names; Names Starting With $STATIC$?

Sep 5, 2011

I am doing work for a client who has lost the source code for one of their VB.Net WinForms applications. The assembly they have is not obfuscated at all. I am trying to recover as much of the source as I can as C# source and have tried several tools for decompiling assemblies, including Reflector, ILSpy and JustDecompile (all the latest versions), but they all produce code with a huge number of errors in them. Because of the large number of errors in the generated code, I am going to ask about the specific errors (in different questions), get more directed answers and in this way try shed some light on why all the tools are having difficulty decompiling this assembly. This question pertains to the fact that the code generated by all these tools always have a large number of invalid member variables (fields) such as the following:

private short $STATIC$Report_Print$20211C1280B1$nHeight;
private ArrayList $STATIC$Report_Print$20211C1280B1$oColumnLefts;
private StaticLocalInitFlag $STATIC$Report_Print$20211C1280B1$oColumnLefts$Init;

why the generated code has these invalid member variables?

View 3 Replies

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

Using Variables In Control Names

Oct 11, 2011

I would like loop through control names at run time. Is it possible to do something like the following:

[Code]...

View 3 Replies

Using Variables In Label Names?

Dec 25, 2009

I have a series of labels to modify through a loop. here's an example of the code i need to modify

lbl1.forecolor = color.black

lbl2.forecolor = ...

I need to iterate the lbl number each time through the loop as the color value will change from label to label.Clueless on how to do so with a loop vs the "long" way of doing code for each separate label. I have 169 to modify each time I change input so I'd rather not unless I have to

View 18 Replies

Grouping String Variables With Their Names?

Dec 13, 2010

I am trying to reduce the amount of code I have and make it more maintainable and flexible. (I.E Do it the right way). I have a bunch of (48) Form controls (text boxes) and when I click next on that form I save all their text values to some 48 global string variables. The names of these variables are the same as the Text Boxes but with "_saved" appended to them.

For any given operation instead of having a separate line for each control it's nice to just use a loop. I can easily write some code to operate on each Control (set visibility, enabled etc) by using Me.Controls and a For Each Loop. I can even make collections of fractional groups of the 48 controls. For example, If cntrl.name.startswith("sometext") collection.add or perform some other operation only on that subgroup etc.

I'd like to do something similar with my Saved Public String Variables. For example I would like to do the following loop somehow but don't know how to group Variables together and keep their name in a way where I can define that array or collection on 1 line or just a couple lines.

' But this next line only groups the values
Group_of_string_Variables = {Var1, Var2, Var3, Var4}
For Each Name_of_String_Variable In Group_of_string_variables

[Code].....

But I can not access the name of a variable or find a way to easily group in key/value 48 different ones without needing much more than 50 lines of code to make either a 2-dim array, a collection, or a hash.

I'm sure someone will tell me I should be doing it a completely different way. That would be ok as long as I don't have to change too much of my other code. I thought of making an object of some kind instead of a variable so I could access 2 object properties- name and value then I could group those objects in a collection as I have done before. But that seems like it would be many more lines of code and I'm not sure it would work.

View 6 Replies

Setting Variables To Use As File Names?

Sep 10, 2009

We have this current VBA program to help us with AutoCAD via the use of a template excel sheet.The setup we have created works well; however occasionally we have two drawings per folder, which often results in, two templates excel sheets of the same name, one overwriting the other. how I can set the active drawing name in a variable that our program uses to check for, then if not present that it creates a copy of out template and then saves it as the active drawings file name which was set as the variable

This would allow our program to locate the associated excel sheet by name then save it by the unique drawing name and prevent existing excel files being overwritten if in the same folder.

;===CODE STARTS HERE===
Option Explicit
Private Objexcel As Excel.Application
Private ObjWorkbook As Workbook

[code]....

View 1 Replies

Using Variables Inside Object Names?

Oct 6, 2008

This is my first post here at Xtreme VB Talk. I just started programming 2 semesters ago. I am currently working on a program but I am having a little trouble with the length. I am trying to take the integer entered in a text box and using it inside the name of another object.

[Code]...

View 5 Replies

VS 2008 Using Variables In Object Names?

Jun 18, 2009

project i'm working on for school. Need to make a grade calculator thing but I'm trying to make my code more efficient.

This is what I have at the moment:
txtID.Text = ListBox1.SelectedIndex
txtFname.Text = namesarr(ListBox1.SelectedIndex, 0)

[code].....

View 8 Replies

Asp.net - Update Linq To Sql With Variable Names?

Apr 15, 2012

im pretty much a beginner to using ASP.net and linq to sql but what im trying to do is update a column of a table based on a variable. at the momment i have

Dim db As New sqldcDataContext Dim update As tableName = (From i in db.tableNames _ Select i)

i think this selects everything, how could i have two variables, one to store what table to update and the other what column. is this possible?edit: sorry for being unclear im trying to make this as dynamic as possible so i dont have to type in the exact table/col names. something like this but in the linq to sql syntax.

mysql_query("SELECT * FROM ". $table ." WHERE `" . $column . "` = "" . $data ."");

View 2 Replies

C# - Nested Excpetion Variable Names

Aug 13, 2010

Given the following code:

try
// code1
try

[Code]....

Are there any side effects to naming the two exception variables the same or should they have different names?

View 2 Replies

Stripping Variable Names From Assemblies

Mar 29, 2010

I'm trying to reduce as much as I can my VB.Net assembly side, and I just figured out that all variable names were kept unchanged in the actual assembly. Since I tend to use pretty long var names, it adds up and, by running dotfuscator on my assembly, I could shrink it by as much as 10%.

[Code]...

View 2 Replies

Access Private Class Variable Names?

Jan 9, 2009

Trying to understand the best way to do this and I'm can't get it figured. Here's basically what I have:

Public Class CardParsingClass
Private iAcctIDStart as integer
Private iAcctIDLength as integer

[code]....

I've only included 2 of the class level fields here but there are actually 30, so that's why I was hoping to be able to send the name of the field to set and the value to set it at in the SetValue function. So in some other routine in the program I'd like to be able to issue the following call:

SetValue("iAcctIDStart", "3")

But then when I get into the SetValue routine, I'm not sure how to proceed. I thought about a case statement that would basically be this:

select Case strFieldToSet
case "iAcctIDStart"
iAcctIDStart = cint(strValue)

[code]....

View 5 Replies

Parse Variable Names And Operate From String?

Jun 10, 2011

I'm using a Microsoft Word form template to create objects in a form programatically, so depending on the information read by the program from the template.

So, I've got some fields where I store formula data for the form, in which I specify that the value for that field is obtained by multiplying other fields in the template. So I store in the string something like this:

"Text1.Text * Text2.Text"

So I need to convert these string values into variable calls to actually operate these values.

View 2 Replies

VS 2005 Declare Dynamic Variable (names)?

Dec 7, 2010

I'm looking to create multiple variables based on a counter object. For example if a counter object is 6 I want to create 6 instances of the variable mText

Something like:
Dim i as integer
Dim Count as integer = 6

[code].....

View 1 Replies

VS 2010 Accessing Variable Names At Runtime?

Sep 30, 2010

Is there any way to access your variable names at runtime? Is there any kind of collection you can loop through?

View 2 Replies

Repetition For List Of Settings With Unique Variable Names

Aug 12, 2011

this website seems great and this is my first post. Sorry if this has already been answered but I have been searching for a long time. I have a program with a list view in details mode. I have it load column settings (visibility, display index, width, etc.) when the form is opened and save them when closed. There are many columns...about ten so far...like folder, file, size, etc. Is there a way to access variable names from the values of other variables?

[Code]...

View 3 Replies

.net - Populating A List Box With Variable Names From LINQ Generated Class?

Nov 17, 2009

I'm quite new to Visual Basic - using Visual Studio 2008 and can't seem to find a way to do the following:

I have a few tables in a SQL Server database and have used LINQ to SQL to create classes of those tables.

Here's a cut down example of what I'd like:listbox1 filled with table names - APS, SMPS, WCPC, CFLAPS
Then from the SelectedIndexChanged event, listbox2 should populate column headers of the selected table.

I have no issues getting data from the database, and can access all of these headers through the anonymous type objects created from a LINQ query (eg APS.ID, APS.count etc), but populating a listbox with these variable names rather than the data inside them seems rather elusive.

This is probably a cross platform coding question rather than VB specific, so if you have a solution in C# or whatever I'd be happy if you could let me know.

View 2 Replies

Reflection - How To Get Variable Names Types / Values In Current Class

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

Visual Studio Upgrade Wizard Hates Some Of Variable Names

Aug 13, 2009

I am upgrading a VB6 to VB.NET project using the upgrade wizard.I know this is going to give me a lot of grief, but I am trying to make the old application useable. I'd rewrite it if I had time but am currently finishing up a summer internship and would like to get something working.One thing the wizard is doing that I can find no justification for is renaming of random variables. [code] For the life of me I don't understand why this is changing left. It isn't a reserved name as far as I can tell, there is no other variable named left that I can find in scope, and renaming it does not create a compiler error. [code] It does this to seemingly random variables throughout my project. Anyone have ideas as to why it doesn't like some of my variable names?

View 3 Replies

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

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

Get The Directory Names Of Each Folder Below The "Shows_path" Variable?

Feb 2, 2010

I'm trying to get the directory names of each folder below the "Shows_path" variable. If Shows_path=X:MultimediaTV Shows and X:MultimediaTV Shows contains STTNG, X-Files, and BSG, the following code produces:

X:MultimediaTV Shows
X:MultimediaTV Shows
X:MultimediaTV Shows

[Code]......

View 3 Replies

Variable Class Names - Rename My Class Human To Man

Dec 18, 2009

What i'm trying to do:

I've got a library which includes a class:

Class Human
End Class
and another class which refers to the human class

Class ASD
Private somevar as new Human
End Class

Ok now i've got a problem, i wish to rename my class Human, to Man. i've got to change Human to Man 2 times, which is OK but the problem is that in the real case, its not just 2 times, its like 500 times or more.

Well its something like a PHP on Javascript.

the following shows the solution of what i'm trying to do, but its in another language PHP/Javascript:

note: in php $ sign declares a variable, echo writes the variable out

CODE:

Is there anyway to do that with VB?

View 6 Replies

Set The Column Names To The Same Values As Table Names Yet The Data Is Not Showing In Form Load?

Aug 15, 2011

I have a DataGridView which populates from an SQL query just fine in default mode

using these table names
[firstName] [varchar](20) NOT NULL,
[lastName] [varchar](20) NOT NULL,

[code]....

I have edited the column headers and set the column names to the same values as my table names yet the data is not showing in form load I have set datagridview.AutoGenerateColumns = False I know the data is there if I delete datagridview.AutoGenerateColumns = False then the data is shown with the default headings?

View 3 Replies

VS 2008 Sharing Variables - Private Sub Could Use The Variable Created On Private Sub

Jul 23, 2010

if for example i have two private sub I declared a local variable on private sub a... is there a way that private sub b could use the variable created on private sub a? Im asking because im in a problem in my app were using global variable is not an option to make the long story short

View 5 Replies







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