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


ADVERTISEMENT

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

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

VS 2008 - Creating Unique File Names?

Dec 22, 2009

I am creating files and then allowing the User to browse through the files via a ComboBox. I decided to name each file the current date. In order to create multiple reports each time the application is ran, each report needs a unique name.

The idea is that if they run a report once a day they'll have a unique report each day. But, then I realized that it is feasible that User could run a report more than once a day. So, I decided to create an integer and increment it each time the report has been ran. Then append the file name with that integer. So, report one of that day would show something like this:

12-22-2009_1 and so on.And this works just fine. But, if the user decides to close the app and then run the report later that day, the variable has been reset and no longer works as needed.I'm using a StreamWriter to create the file.

View 6 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

.net - Creating Global Variables In Asp.net Using C#?

Nov 25, 2009

I was working on window appication previously where i used to create global variables using modules in vb.net, but i found that in C# there is no concept of modules. so how can i create global vaiables in C#

View 9 Replies

Creating Same App With Different Variables Values

Feb 21, 2010

I would I have a program that I use in the computer in my network, but for every user I need to edit the source to this user, thus the user cannot edit his information, just use the program how it was ... So, looking over the internet I found a "program" that may contains my solution... Its a Keylloger, I'm not meaning use this keylogger, no, but it has a a very interest feature: I use the main form to edit the information then after all it create a new program with the new information inside... I use my main program to create every userprofile then my program create a new program with the profile inside...

View 12 Replies

Creating Variables And Populating From XML?

Feb 25, 2011

I have created a script in powershell that has done this, but amo moving to a VB app and am having troubles.The snippet that I am adding shows what I did in powershell. I created variables using the XML and from a SQL database compared them, and updated the XML to reflect changes pulled from the database. I want to cycle through creating the variables as more may be added in time and want to make sure I don't have to keep adding code to pull out the data manually one node at a time.rudimentary code as I am new to both powershell and VB. Currently using VS2008.

code/xml below.
$xml = New-Object XML
$xml.load("g: estingackup_local_config.xml")[code].....

View 2 Replies

VB - New Project - Creating Variables ?

Nov 29, 2010

I'm studying visual basic and wanted to know where I place my code in the new project which looks like this below:

Public

Class Form1

Private
Sub Form1_Load(ByVal sender

[CODE]...

I'm creating variables.

View 7 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

Accessing And Creating Variables Inside A For Loop?

Oct 15, 2011

I have some variables that are distinct by numbers, like in1, in2...If I have for loop, how would I access those variables, using the counter, and attaching it to the variable?I believe in JAVA, you could just use in+ct... where ct is the counter to access the variable.also how could you make a new variable in the for loop?Initially I had variables declare outside of the for loop. The problem was how to access those variables using the for loop.

var_nm1 = in1.Text
var_nm2 = in2.Text
var_nm3 = in3.Text
Dim nmList(2) As Integer

[code]....

This is object oriented programming, and I made the textboxes in1, in2, and in3 using the GUI editor. that was so easy.

View 10 Replies

Creating Temp Local Variables - Bad Practice?

Jan 12, 2012

When I want to maintain code readability and keep things neat. I would create temp variables . Below is one of my functions that uses it. Is it a bad practice? I would create temp variables cost more memory ?

Private sub test(byref transac as transaction , byref txntime as string )
Dim cmd as OracleCommand = nothing
Dim Adapter As OracleDataAdapter = nothing
Dim SQLStr As New StringBuilder
[Code] .....

View 9 Replies

Creating Variables Based On Textbox Input?

Nov 6, 2011

I have a form with a few text boxes, one of which has it's contents stored to a integer variable.

The value stored will end up being one of a few numbers ranging from 12 to 98, and I need to the same number of new variables as the number in the textbox.

Can I automate the creation of new variables based on the value stored, or do I need to define the max number required and just ignore the rest when using less?

View 2 Replies







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