473,624 Members | 2,240 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

232 New Member
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 2632
Seth Schrock
2,965 Recognized Expert Specialist
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 Recognized Expert Moderator MVP
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,567 Recognized Expert Moderator MVP
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
8381
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 logindisabled=FALSE Instead of parsing this text and assigning the values, I was wondering
7
1348
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
5527
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 using the elipse. For example, a funciton could take in 1 known type, then a variable list of other parameters: ReturnValueClass rvc = someFunction("Some known type", 1, 0.2, "string"); ReturnValueClass rvc2 = someFunction("Some known type...
3
1278
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 not cast a string and switch the value, that seems a bit redundant. So an example would be: // SimpleBaseTypes MyType; MyType = bool;
5
5955
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 event is fired by one of the controls contained in the User Control, these variable are reset. Here is my current code (I have a little more to add later, right now I am just concerned about the variables getting reset): Public Class DatePicker2...
20
6953
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 = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
1
1388
by: Eric | last post by:
Is it possible to create a mirror from 1st subform variable into 2nd subform variable.
6
1361
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
12719
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 AutoExec macro calls a function "InitApplication" which, in turn, calls a function to set the value of a global string variable
1
1155
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'
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8488
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7170
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4183
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1793
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1488
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.