I have a database with unique ID numbers. Each id number has images connected to it.
For Example:
www.mysite.com/images/1/4/778814.jpg
www.mysite.com/images/"T"/"U"IDNUMBer.jpg
As you will see the "T" folder comes from the tens spont of the id number. The "U" folder come from the units spot and the image name is the ID and then I have to add jpg. Now i would never create a database like this but that is what this company is supplying me. My question is how to make asp split the id number up to use in other locations.
Thanks
RustyI can think of 2 options. See which is best for you based on the datatype of the idnumber.
a) You can work with strings and use
Dim unit, tens as String
unit = idnumber.ToString().Chars(idnumber.ToString().Length -1) 'to get units character
tens = idnumber.ToString().Chars(idnumber.ToString().Length -2) 'to get the tens character
b) Work with integers and use mathematical operators Eg:
Dim idnumber As Integer
idnumber = 456789
Dim unit, tens As Integer
unit = idnumber Mod 10 ' Returns 9
tens = (idnumber Mod 100) \ 10 ' Returns 8
Use the Split method to split the string by "/" and then you can use each of the elements of the created Array to grab the numbers.
string fullUrl = "www.mysite.com/images/1/4/778814.jpg";
string[] splitParams = fullUrl.Split('/');
splitParams[0] is "www.mysite.com"
splitParams[1] is "images"
splitParams[2] is "1"
splitParams[3] is "4"
splitParams[4] is "778814.jpg"
HTH
DJ
0 comments:
Post a Comment