473,327 Members | 2,071 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,327 software developers and data experts.

converting string to variable

2
dim a_1, a_2, a_3,i
a_1=x
a_2=y
a_3=z

for i=1 to 3
response.write(a_ & i)
next


result should be: xyz

But the expected result is not coming.
there is an error in response.write()


pls. help me to solve it.

note: i want ASP coding
Jun 26 '10 #1
5 1752
code green
1,726 Expert 1GB
Think it should be more like
Expand|Select|Wrap|Line Numbers
  1. response.write('a_' + i)
  2.  
Jun 28 '10 #2
You cannot pass a name of a variable as string.
Why don't you use array:

dim a()
dim i
redim a(i)

a(0)=x
a(1)=y
a(2)=z

for c=0 to i
response.write(a(count))
next
Jun 28 '10 #3
dim a()
dim i
i = 2
redim a(i)


a(0)=x
a(1)=y
a(2)=z

for c=0 to i
response.write(a(count))
next
Jun 28 '10 #4
Sorry, another typo

dim a()
dim i
i = 2
redim a(i)


a(0)=x
a(1)=y
a(2)=z

for c=0 to i
response.write(a(c))
next
Jun 28 '10 #5
jhardman
3,406 Expert 2GB
Viktorka's solution is the best, but this will also work (I use a similar approach for form inputs all the time):
Expand|Select|Wrap|Line Numbers
  1. session("a_1") = x
  2. session("a_2") = y
  3. session("a_3") = x
  4.  
  5. for x = 0 to 2
  6.    response.write session("a_"+x)
  7. next
Jared
Jun 29 '10 #6

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

Similar topics

16
by: PK9 | last post by:
I have a string variable that holds the equivalent of a DateTime value. I pulled this datetime from the database and I want to strip off the time portion before displaying to the user. I am...
5
by: VM | last post by:
If I have a string variable with a formula: string sMyformula = "3.3*5.2*5"; How can I convert this to a mathematical formula that the compiler can calculate? For all purposes, the formula in...
2
by: Jason C Reynolds | last post by:
Hi, I've came up short on an answer to this: Is there a way to find out if a string variable contains valid rtf text? I got around by trapping the error and just setting the .text property instead...
12
by: Slonocode | last post by:
Hello I am trying to display a USA address properly in a multiline textbox. Unfortunately the address I must process is contained in a string variable and the format is not uniform. Examples: ...
3
by: SiewSa | last post by:
I have come to a situation that I need to use the result of a string variable as a formula for performing calculation. As an example below: Dim X As Integer Dim Y As Integer Dim Result...
4
by: JohnR | last post by:
Hi all, I'm finally sick and tired of manually generating get/set properties for each private variable in a class so I'm trying to create a macro to do it. I'm stuck because I can't figure out...
9
by: priyanka | last post by:
Hi there, I want to convert a String into integer. I get the string froma file using : string argNum; getline(inputStream,argNum); I now need to convert argNum into integer.
2
by: atlkhan | last post by:
Hi I am trying to pass a string variable to a function which takes character type parameters like function (char fname) //defination of function but i am calling it like function(...
2
by: Ajak | last post by:
Hello, I'm converting a VB6 app to VB2005 which uses a third party API dll. The API function accepts structure as its parameter (byRef). Below is the struct (shortened for clarity):- ...
2
by: Looch | last post by:
All, I'm trying to output but I can only get (brackets for clarity) when using the code below. How can I "break" into the query variable in the InsertName method to add the name parameter to...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
1
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.