473,395 Members | 1,742 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,395 software developers and data experts.

VB.NET: How do I create a variable name programmatically?

I want to create a variable name programmatically.

For instance:
Dim GlobVar as String = "My.STL."
Dim VarName as String = "sAccountNo"
Dim VarValue as String = "ABC123"

I want to end up with the following line of code, assigning a variable a value:

My.STL.sAccountNo = "ABC123"

How do I programmatically create the variable name?
Nov 4 '07 #1
1 3544
balabaster
797 Expert 512MB
I want to create a variable name programmatically.

For instance:
Dim GlobVar as String = "My.STL."
Dim VarName as String = "sAccountNo"
Dim VarValue as String = "ABC123"

I want to end up with the following line of code, assigning a variable a value:

My.STL.sAccountNo = "ABC123"

How do I programmatically create the variable name?
I'm interested to hear if anyone has an answer to this that will work in the manner you imply. The only way I can think of to simulate something close would be to create a class:

Expand|Select|Wrap|Line Numbers
  1.  Public Class MyDemoClass 
  2.   Public Properties As New PropertyCollection
  3. End Class
  4.  
  5. 'In your main code
  6. Dim oClass As New MyDemoClass
  7. oClass.Properties.Add("MyFirstProperty", "Value of first property")
  8. MsgBox oClass.Properties("MyFirstProperty")
As you can see...it doesn't work in quite the manner you're looking for - but it does allow you to create a dictionary of properties to store values in.
Nov 4 '07 #2

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

Similar topics

6
by: Null Reference | last post by:
Anybody here who can explain or point me to a link ? I wish to create a blank MS Access DB file programmatically using C# . Thanks, nfs
5
by: Saga | last post by:
Hi all, I just read the thread by the same name posted on Jun 15, 9:45 AM, but I am looking at it from a different point of view. I came across this question in terms of functionality. Are VB and...
9
by: Anthony | last post by:
To me, creating Excel 2003 spreadsheets programmatically via VB.NET hasn't really changed since the days of VB6. That is, I'd do something similar to this Code: Dim ExcelApp As...
1
by: Crash | last post by:
Hi, ..NET v1.x SP1 VS 2003 SQL Server 2000 SP3 Server 2000, XP, Server 2003 I would like to programmatically execute {possibly many} SQL Server batch scripts. Aka I have many scripts that...
9
by: craig.overton | last post by:
All, I am currently developing an FTP class in VB.NET. It's kid tested, mother approved when trying to access an FTP Server on a Windows box meaning I can connect, run commands, upload and...
14
by: Anoop | last post by:
Hi, I am new to this newsgroup and need help in the following questions. 1. I am workin' on a GUI application. Does C# provides Layout Managers the way Java does to design GUI? I know that it...
3
by: ezmeralda | last post by:
Hello, I have some code which shall be compiled in .NET v1.1 and v2.0 but which has to be different for the two .NET-Versions. Therefore I need to use a construct like #if NET_20 <2.0...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
0
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.