|
-
Jun 25th, 2005, 12:53 PM
#1
Thread Starter
New Member
Trim a DB field
I have this code and it works great for some of the numbers but not ther other.
<%# Mid(DataSet1.FieldValue("ListNum", Container).Trim(), 5,1) %> with a number of 675432 the result would be 3. With a number of 75432 the result would be 2. I need them always be in the 2 spot even if my field has a 7, 6, 5, or 4 digit numbers in it.
This is trimming the ListNum field in my database down to one number. When the database field is 6 numbers long it works perfectly. If the database number is 5 numbers long it selects the last number instead of the 2nd to the last number. Is there a way to get the trim command to count the numbers from the right and not the left. So the code would look something like this.
<%# Mid(DataSet1.FieldValue("ListNum", Container).Trim(), 2,1) %>
Thanks for any help.
-
Jun 25th, 2005, 01:16 PM
#2
PowerPoster
Re: Trim a DB field
Try something like this:
Dim myString as string
myString = DataSet1.FieldValue("ListNum", Container).Trim()
myString = myString.Substring(myString.Length-2, 1)
-
Jun 25th, 2005, 01:46 PM
#3
Thread Starter
New Member
Re: Trim a DB field
The code is a section out of much more.. Here is the code all together.
<img src="http://photos.neg.ctimls.com/neg/photos/small/<%# Mid(DataSet1.FieldValue("ListNum", Container).Trim(), 5,1) %>/<%# Right(DataSet1.FieldValue("ListNum", Container).Trim(), 1) %>/<%# DataSet1.FieldValue("ListNum", Container) %>a.jpg" width="100" alt="">
Because it is a piece of a code that is why I can't use something like that. Also there are many of these for one page on the site so I have to keep it as simple as possible.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|