Results 1 to 3 of 3

Thread: Trimming Text for a certian charachter or word

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2005
    Posts
    5

    Trimming Text for a certian charachter or word

    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

    Rusty
    Last edited by russler01; Jun 23rd, 2005 at 11:23 AM.

  2. #2
    Member Nikhil Aggarwal's Avatar
    Join Date
    Jun 2005
    Location
    New Delhi, India
    Posts
    36

    Re: Trimming Text for a certian charachter or word

    I 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
    VB Code:
    1. Dim unit, tens as String
    2. unit = idnumber.ToString().Chars(idnumber.ToString().Length -1) 'to get units character
    3. tens = idnumber.ToString().Chars(idnumber.ToString().Length -2) 'to get the tens character
    b) Work with integers and use mathematical operators Eg:
    VB Code:
    1. Dim idnumber As Integer
    2. idnumber = 456789
    3. Dim unit, tens As Integer
    4. unit = idnumber Mod 10                                   ' Returns 9
    5. tens = (idnumber Mod 100) \ 10                        ' Returns 8
    Nikhil Aggarwal

  3. #3
    Frenzied Member dj4uk's Avatar
    Join Date
    Aug 2002
    Location
    Birmingham, UK Lobotomies: 3
    Posts
    1,131

    Re: Trimming Text for a certian charachter or word

    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.

    Code:
    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

    If I have been helpful please rate my post. If I haven't tell me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width