Results 1 to 4 of 4

Thread: String doesn't fit in label

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    The Netherlands
    Posts
    96

    String doesn't fit in label

    This is probably very very easy...i think there's some pre-made function in VB for it..but I can't find it...

    I have a string...."sgsdgkjdsglkdjglkdjglkdjfglkdgjlkdg"
    And a label which can hold up to 8 character and 4 lines (for examle)

    When I use
    VB Code:
    1. label1.Caption = xstring
    it will only show the first 8 characters....

    But I want it to have the first 8 on the first line..and the next 8 on the next line..

    So I need a function to split it and enter space between it...(I suppose)

    If the string is "sgsdg kjdsglkdjg lkdjglkdjfgl kdgjlkdg" then it will work fine...
    Last edited by Chrissie; Oct 16th, 2002 at 03:45 AM.

  2. #2
    Lively Member
    Join Date
    Sep 2002
    Location
    Singapore
    Posts
    93
    Just re size your label?
    Or maybe use instr to check if word is at the 8th position, make a " & vbcrlf "
    An elephant learning VB..

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2002
    Location
    The Netherlands
    Posts
    96
    Resizing the label is no option...
    Checking for the 8 position is not an option...
    consider the string is "blas bladf" - there is a charachter at the 8 position but I don't want it to be split as there's already a space in the word in front of it...

  4. #4
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Use Split on spaces.
    Step throuugh the array for any item with more than 8 characters.

    OR

    Step through the string character by character.
    When you get to a space, start the special count again.
    When you get to 8, add a space and start the special count again.

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