Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

String Split on Line Break

Tags:

vba

ms-access

I have a textbox on a MS Access form that users are going to copy a column of numbers into from an excel spreadsheet. I need to take this input and use it as parameters to build a query. I have code that looks like this

Dim data as variant
Dim input as String
data = Split(input,vbLf)

I want to be able to build a list of the input from the users but I can't figure out how to split it on the line break. I've tried "\n\r", "\n". "\r", vbCrLf, vbLf. The input looks like "12345[][]23456" with the box characters between each number

Thanks

like image 622
jim Avatar asked Sep 17 '09 14:09

jim


People also ask

How do you split a string with a new line?

Split String by Newline in Java 8. Java 8 provides an “\R” pattern that matches any Unicode line-break sequence and covers all the newline characters for different operating systems. Therefore, we can use the “\R” pattern instead of “\\r?\\ n|\\r” in Java 8 or higher.

What does line split mean?

It means that your line is a String of numbers separated by commas. eg: "12.34,45.0,67.1" The line. split(",") returns an array of Strings.

How do you split a string by line in Python?

To split the line in Python, use the String split() method. The split() is an inbuilt method that returns a list of lines after breaking the given string by the specified separator.


2 Answers

I got Split to work for me using vbCrLf. I also wrote the result of Split to a String array.

Here's my code:

Dim data() As String
Dim yourInput As String
data = Split(yourInput, vbCrLf)
like image 95
Jay Riggs Avatar answered Sep 26 '22 02:09

Jay Riggs


vbCRLF worked for me, try: Strings.Chr(13) & Strings.Chr(10) (which is vbCRLF)

try to see what is the ASCII code of those 2 boxes:

    //ex for input = "12345[][]23456"
    Strings.Asc(Strings.Mid(input, 6, 1)) 
    Strings.Asc(Strings.Mid(input, 7, 1))
like image 26
manji Avatar answered Sep 26 '22 02:09

manji