473,320 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

create a new variable with concatenation from the value of previous variable

232 100+
I want to create a new variable with concatenation from the value of previous variable with use of concatenation
Expand|Select|Wrap|Line Numbers
  1. Sub test()
  2. v1 = "2"
  3. ''create new variable v12 whose value is 3
  4. v1.[&v1] = "3"
  5. Debug.Print v12
  6. '' above should print 3
  7. End Sub
error is invalid or unqualified reference
please help
Oct 14 '17 #1
3 2612
Seth Schrock
2,965 Expert 2GB
Line 4 is not a valid statement. I'm not sure what you are trying to do. Simple variables (like v1) don't have any properties or methods (anything after the dot). Simply entering v12 = "3" for line 4 would get the result of Debug.Print to be 3. However, there isn't any dependence on the variable v1 using this method.

Please try to explain again what you are trying to do as you can't concatenate anything with "3" and get simply "3" other than an empty string.
Oct 24 '17 #2
Rabbit
12,516 Expert Mod 8TB
You can't dynamically create variable names. I don't know where you pulled that syntax from but it's not VBA syntax.

If you want to store key-value pairs where you can dynamically create the key name, use a dictionary object.

However, that's only addressing your stated request. At the root of everything, you probably don't need this sort of functionality in the first place. We don't know why you want to create dynamic variable names. If we understood why you want to do this, then there's probably an easier solution and you don't need to create these dynamic variable names in the first place.
Oct 24 '17 #3
NeoPa
32,556 Expert Mod 16PB
As Rabbit says, Arrays, Collections or Dictionary Objects seem to offer the sort of thing you look like you might be after. Without better sense in the question though it's hard to guess how to help further.
Oct 30 '17 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Mike | last post by:
Is there any way I can use a function to create a variable and assign a value to it? I have a Perl script that returns some LDAP information: sn=Shore givenname=Mike logintime=20041008153445Z...
7
by: hpy_awad | last post by:
I need to make the size of an array as variable read from screen . How can I do it ?
10
by: Clay_Culver | last post by:
I have heard that it is possible to use classes + template magic to make standalone functions (or maybe just a functor which acts like a function) which can accept variable length arguments without...
3
by: Nick Weekes | last post by:
Im trying to create a variable that can store all possible simple C# types. This is so I can assign the type to a database column, regardless of whether its string, int, bool etc. But, Id rather...
5
by: Nathan Sokalski | last post by:
I have a user control that contains three variables which are accessed through public properties. They are declared immediately below the "Web Form Designer Generated Code" section. Every time an...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
1
by: Eric | last post by:
Is it possible to create a mirror from 1st subform variable into 2nd subform variable.
6
by: =?Utf-8?B?bGlhbnF0bGl0?= | last post by:
lets say there are 3 int ncount variable in every method private void x_method1() { int ncount = dv.length; } private void x_method2() { int ncount = drarr.length;
20
by: teddysnips | last post by:
Weird. I have taken over responsibility for a legacy application, Access 2k3, split FE/BE. The client has reported a problem and I'm investigating. I didn't write the application. The...
1
by: amel86 | last post by:
hello. please help me how can i add one more variable at this code > onChange="getmodel('mlm-edit.php?category='+this.value)" for example i want add 2nd value besides 'this.value'
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.