Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Typecasting and Arrays! 1

Status
Not open for further replies.

Dogers

MIS
Jul 23, 2002
236
GB
if i had a bit of asp code, such as:

dim temp
temp = recordset.fields("afieldname") (note- field "afieldname" is a string in the db)

what is temp? I seem to be unable to use the left() or mid() functions on it..!

failing that, is there any way to get a string stored in a DB into an array, hacking the string apart where the line breaks are? (ie, after each line break in the string, the next line goes to another element in the array)
 
Temp should hold the entire contents of the field returned. VBScript is loosely typed so all variables are of datatype variant. Therefore left() and mid() should work just fine, so should:
strArray = split(recordset.fields("afieldname"), chr(13))

to split your string into an array. Actually, I would doit this way...
temp = recordset.fields("afieldname")
temp = replace(temp,chr(10),chr(13)) 'to make all line feeds into carriage returns (you may have both)
strArray = split(temp, chr(13))

Make sure that your recordset has actually retrieved the value that you think it has because your string functions should work just fine if there is a string in your variable...


Maybe you could post the code that loads the data into the recordset... -- Just trying to help...
[wolf]<--- This is a wolf? We need a new icon.......
mikewolf@tst-us.com
 
ahaa! i knew there had to be an easy way to split up strings..

I've been using PHP for quite some time and just come back to ASP :)

I'll give the split() function a go, it ought to work.. if not i'll come back with more code, ta ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top