Results 1 to 11 of 11

Thread: [RESOLVED] Cannot split text using vbCrlf as delimiter

  1. #1

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Resolved [RESOLVED] Cannot split text using vbCrlf as delimiter

    I pulling my hair on this one. Split is not working.

    Dim sometext as string


    myArr() = Split(sometext, vbCrLf)

    Sample data. The data is stored on sometext variable already.

    Code:
     “ajkdhaljkhlkjaddfj ka gdkjgaslkjdgasjkd”:
    asjkldh dfjkljgsd glakfjsfadj aldkjalkjs sl sdklfjslk fsdlkf aldjkaklsd asd klasdlkjaslkd asdjasd.
    Code:
    under immediate window when i try 
    debug.print myArr(0)
    “ajkdhaljkhlkjaddfj ka gdkjgaslkjdgasjkd”:
    asjkldh dfjkljgsd glakfjsfadj aldkjalkjs sl sdklfjslk fsdlkf aldjkaklsd asd klasdlkjaslkd asdjasd.
    
    myArr(1) will return an error.

    Can somebody help me on this one?

  2. #2
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Cannot split text using vbCrlf as delimiter

    Does InStr(sometext, vbCrLf) return >0

    Maybe it's not a full carriage return/line feed, it could be just one of those. Try Splitting with vbCr or vbLf

  3. #3
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Cannot split text using vbCrlf as delimiter

    Also try

    Code:
    myArr() = Split(sometext, vbnewline)
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  4. #4

  5. #5
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: Cannot split text using vbCrlf as delimiter

    I think vbCrLf constant is identical to vbNewLine. The latter one probably being newer (more verbose) and the former kept for backwards compatibility.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: Cannot split text using vbCrlf as delimiter

    Quote Originally Posted by baja_yu View Post
    I think vbCrLf constant is identical to vbNewLine. The latter one probably being newer (more verbose) and the former kept for backwards compatibility.
    Yres, they are the same (asc 13).

  7. #7

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Cannot split text using vbCrlf as delimiter

    I tried vbNewLine same. It didn't split.

    InStr(1, sometext, vbCrLf) returned 0 OMG!!!!

  8. #8

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Cannot split text using vbCrlf as delimiter

    This is unreal. Immediate Window is showing clearly that the variable has newline. why it wont split? I really don't know what is causing this.

  9. #9

    Thread Starter
    Frenzied Member zynder's Avatar
    Join Date
    Nov 2006
    Location
    localhost
    Posts
    1,434

    Re: Cannot split text using vbCrlf as delimiter

    LOL i missed reading post #2. VbCR worked like a charm. Woot +1 to all that helped!

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [RESOLVED] Cannot split text using vbCrlf as delimiter

    vbCrLf is just a "hard-coded" Carriage Return and Line Feed.

    vbNewLine is platform specific and will contain whatever the appropriate codes are to generate a new line

    Anyways if you try as Baja suggested

    myArr() = Split(sometext, vbLf)

    Then it will work. I just tried it...
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  11. #11
    Next Of Kin baja_yu's Avatar
    Join Date
    Aug 2002
    Location
    /dev/root
    Posts
    5,989

    Re: [RESOLVED] Cannot split text using vbCrlf as delimiter

    That's right kool. Here are the definitions from MSDN

    Const vbCrLf = "
    "
    Member of VBA.Constants
    Constant for Carriage-return/Linefeed combination; equivalent of Chr$(13)+Chr$(10
    Const vbNewLine = "
    "
    Member of VBA.Constants
    Constant for NewLine; platform specific
    Though I wonder on which platform can you run a VB6 app that does not use Cr+Lf combination for a new line character.

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