|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
String to a variable
hi guys i have a query, how do you change a string into a variable?
example: DATE_REC= "13/10/2009" non-working bob = "DATE_REC" Response.Write "<br> TESTING:" & bob output: date_rec Working bob = DATE_REC Response.Write "<br> TESTING:" & bob output: 13/10/2009 I need to work out how to get the string converted so i can use it as a variable - any ideas? (reason is this will be in a loop and fed from a recordset) Many thanks |
|
#2
|
|||
|
|||
|
Please explain more what you are trying to do. Show your loop code. What is fed from the recordset - field names, field values? I don't think you can 'change a string into a variable' nor can I understand the need. If you want to refer to the field names in a loop, here is one way I have done it.
Code:
For j = 0 To rsDataOld.Fields.Count - 1
If rsDataNew.Fields(j).Name <> "LabNum" Then
rsDataNew.Fields(j) = rsDataOld.Fields(j)
End If
Next j
Last edited by June7 : October 10th, 2009 at 10:22 PM. |
|
#3
|
||||
|
||||
|
--moved to the classic ASP forum.
what you need is the EVAL function: Code:
bob = "DATE_REC" Response.Write "<br> TESTING:" & Eval(bob) |
|
#4
|
|||
|
|||
|
excellent - eval() worked great - i always thought this was only for use in JAVA - thanks for the knowledge update.
For the previous reply - i needed to be able to do it without specifyng field names in the code, this allows sql to be updated and build the page without having to update the asp. Thanks to both of you. Matt |
|
#5
|
||||
|
||||
|
Quote:
of their most powerful functions, letting you do dynamic things at run time that are not possible in compiled code. |
|
#6
|
|||
|
|||
|
June7 my understanding is that depending whast in the string you can turn it into a vaiable.
e.g. if you have a string like this totalamount = "21676" you can turn this into an iteger by using cint like so cint(totalamount) but obviously if there were any letters in there then it woudl not work. |
|
#7
|
||||
|
||||
|
Quote:
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > ASP Development > String to a variable |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|