Force Character Wrap.

Discussion in 'ASP General' started by Adam, Jan 23, 2004.

  1. Adam

    Adam Guest

    Hello is there a function in ASP that can force a database result to
    automatically wrap at say.. 25 characters in length?

    Reason for this is because I have a database and people could go in and put
    a message like

    "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"

    and when it is displayed on the site it will make the layout all messed up.

    If someone knows how to do this I would be very great ful, Thanks!
    Adam, Jan 23, 2004
    #1
    1. Advertising

  2. Adam

    Steven Burn Guest

    Function FormatOutput(strData)
    Select Case Len(strData)
    Case < 25 'Under 25 chars
    'Do something
    Case > 25 'Over 25 chars
    'Do something
    End Select
    End Function

    --
    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!

    Disclaimer:
    I know I'm probably wrong, I just like taking part ;o)


    Adam <> wrote in message
    news:ZkiQb.20366$...
    > Hello is there a function in ASP that can force a database result to
    > automatically wrap at say.. 25 characters in length?
    >
    > Reason for this is because I have a database and people could go in and

    put
    > a message like
    >
    > "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
    >
    > and when it is displayed on the site it will make the layout all messed

    up.
    >
    > If someone knows how to do this I would be very great ful, Thanks!
    >
    >
    Steven Burn, Jan 24, 2004
    #2
    1. Advertising

  3. Adam

    Tim Slattery Guest

    "Adam" <> wrote:

    >Hello is there a function in ASP that can force a database result to
    >automatically wrap at say.. 25 characters in length?
    >
    >Reason for this is because I have a database and people could go in and put
    >a message like
    >
    >"MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
    >
    >and when it is displayed on the site it will make the layout all messed up.
    >
    >If someone knows how to do this I would be very great ful, Thanks!


    Keep in mind that your browser will wrap text, but will only break it
    where there's a space. The long string of Ms above has no space, so
    the browser won't break it. It's likely that the actual data will have
    spaces (though, of course, I know nothing about your data) and will
    break properly.

    I mention this because our testing department made my web app's
    display distort terribly by using a long string of characters with no
    spaces. In real life, the string would be words separated by spaces,
    and would break and wrap appropriately. I wasted far too much time
    figuring that out!

    --
    Tim Slattery
    MS MVP(DTS)
    Tim Slattery, Jan 26, 2004
    #3
  4. "Adam" wrote:
    >
    > Hello is there a function in ASP that can force a database
    > result to automatically wrap at say.. 25 characters in
    > length?
    >
    > Reason for this is because I have a database and people
    > could go in and put a message like
    >
    > "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM"
    >
    > and when it is displayed on the site it will make the layout
    > all messed up.


    If you really want to avoid displaying such messages, why not simply reject
    them instead of inserting them into your DB? Warn the user that his message
    will be rejected (or that it was not recorded due to the long string), and
    leave it at that.

    The easiest way to test for long unbroken strings is with a regular
    expression. Try something like this:

    JScript:
    if (/\w{25}/.test(myVar)) ... //-- Reject string

    VBScript:
    Dim rx
    Set rx = New RegExp
    rx.Pattern = "\w{25}"
    If rx.Test(strMyValue) Then
    ... ' Reject the string
    End If

    VBScript RegExp Object:
    http://msdn.microsoft.com/library/en-us/script56/html/vsobjregexp.asp

    Regular Expression Syntax (applies to both VBScript and JScript):
    http://msdn.microsoft.com/library/en-us/script56/html/js56jsgrpregexpsyntax.asp


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
    Dave Anderson, Jan 26, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Noozer
    Replies:
    22
    Views:
    29,828
    Noozer
    Jan 17, 2005
  2. CRON
    Replies:
    10
    Views:
    20,785
  3. Aaron Fude

    To wrap or not to wrap?

    Aaron Fude, May 8, 2008, in forum: Java
    Replies:
    12
    Views:
    693
    Chronic Philharmonic
    May 10, 2008
  4. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 22, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    226
    Art Werschulz
    Sep 22, 2003
  5. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 24, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    241
    Anno Siegel
    Sep 25, 2003
Loading...

Share This Page