Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Website Design Forum


You are currently viewing our Website Design Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Formatting text in DWMX
Old 04-25-2005, 12:27 PM Formatting text in DWMX
VegaLA's Avatar
Skilled Talker

Posts: 64
Trades: 0
Hi all,
I am trying to format a field so that it displays only a certain number of characters. so if the value in the field exceeds 20 than it will only display the first 20 characters. I checked the formatting feature in the bindings window and tried Trim but it has'nt shortened the value on the page I am displaying it on. I think i'm going about this the wrong way too because the trim, be it left or right, does'nt allow you to state how many characters you'd like to display so is there a way to display a certain number of characters of the value of a field ?

Thanks in advance,
Mitch.......

Last edited by VegaLA; 04-25-2005 at 12:30 PM..
VegaLA is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-25-2005, 12:38 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,381
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
what language ?
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-26-2005, 11:56 AM
VegaLA's Avatar
Skilled Talker

Posts: 64
Trades: 0
I'm using VBScript.
VegaLA is offline
Reply With Quote
View Public Profile
 
Old 04-26-2005, 12:37 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,381
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
use
Code:
str = left(str,20)
to truncate at 20 chars

or

two functions to truncate a string tidily
Code:
function GetSnippet(strIn,intMaxLen)
' extract a snippet of text from string
dim temp
dim EndPos
temp = left(strIn,intMaxLen)
EndPos = InStrRev(temp," ")
temp = left(temp, EndPos)
GetSnippet = temp
end function

function GetSnippetLength(strIn,Word,intRetLen)
' extract a fixed length snippet of text from string
dim lTemp
dim rTemp
dim WordPos
dim intStart
intStart = InStr(strIn,Word)
lTemp = mid(strIn,intStart- intRetLen, intRetLen)
rTemp = mid(strIn,intStart , intRetLen  + len(word) )
GetSnippetLength = "... " & lTemp & rTemp & " ..."
end function
the first will GetSnippet() will extract a fixed length string and will find the nearest space so it doesn't break words up.

the second GetSnippetLength() will extract a snippet from around a word. similar to Googles SERP snippets.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Formatting text in DWMX
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.26086 seconds with 12 queries