|
-
Oct 21st, 2010, 11:30 AM
#1
Thread Starter
Frenzied Member
[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?
-
Oct 21st, 2010, 11:34 AM
#2
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
-
Oct 21st, 2010, 11:38 AM
#3
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
-
Oct 21st, 2010, 11:39 AM
#4
Re: Cannot split text using vbCrlf as delimiter
Or examine the character to see what it is.
MsgBox Asc(Mid$(sometext, n, 1)) ' Where n is the position you want to look at
-
Oct 21st, 2010, 11:46 AM
#5
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.
-
Oct 21st, 2010, 11:49 AM
#6
Re: Cannot split text using vbCrlf as delimiter
 Originally Posted by baja_yu
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).
-
Oct 21st, 2010, 11:51 AM
#7
Thread Starter
Frenzied Member
Re: Cannot split text using vbCrlf as delimiter
I tried vbNewLine same. It didn't split.
InStr(1, sometext, vbCrLf) returned 0 OMG!!!!
-
Oct 21st, 2010, 11:54 AM
#8
Thread Starter
Frenzied Member
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.
-
Oct 21st, 2010, 11:56 AM
#9
Thread Starter
Frenzied Member
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!
-
Oct 21st, 2010, 11:57 AM
#10
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
-
Oct 21st, 2010, 01:30 PM
#11
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|