Separating strings in a single line

user2833837

How do I separate the single line of input into 3 different variables without using arrays? (x,y,z) Each section is separated by a space

Ex. 184 41890 42891

The code I have so far is just reading the line one character at a time in a loop.

    c = Chr(reader.Read)
    s = ""
    Do While (ch <> vbCr) And (ch <> Chr(32)) And (reader.Peek <> -1)
        Select Case c
            Case "0" To "9"
                s = s & c
            Case Else
                MsgBox("Error")
        End Select
        c = Chr(reader.Read)
    Loop
guymid

Do you want to avoid using arrays altogether or just end up with the parts in specific strings? You can do this:

        string input = "184 41890 42891";
        string[] parts = input.Split(' ');
        string myCustomString1 = parts[0];
        string myCustomString2 = parts[1];
        string myCustomString3 = parts[2];

This has problems though because you need to know how many parts there will be so that you can have enough strings set up. The advantage of arrays is that they are flexible and can be whatever size you wish.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Ansible: Looping Multiline Strings into Single Line Strings

Change Multi line strings to Single line

Regex for matching and separating strings

Separating strings with lists

Separating violinplots in seaborn with a line

Separating points/clusters with a line

Read integers and strings from a single line of a console

Getting strings as a list into a single line with beautifulsoup

Matching multiple encased strings in a single line

Extract specific strings from a single long line

Separating Multiple Strings in Paste() with Newline

Separating Strings by Spaces Using gets()

Separating hexadecimal escape sequences in strings

Separating numbers to different strings or an array

Reading multiple files and then separating strings

Separating a part of the strings based on format

Separating Integers and Strings From a List

Separating instances in JTable with an horizontal line

Separating line of text into columns of a dataframe

Python pass multiple strings to a single command line argument

Build CSV from Array of Strings in Swift in a single line of code

Force RSpec 3 to show diff for single line strings?

Cannot get the strings into a single line getting body text using Beautifulsoup

How to append strings from a loop to a single output line?

Process two strings per line, data and process in single bash script

Jenkins multi string parameter printing strings in single line

Trying to fscanf multiple values (3 strings + integer) in a single line

Adding special character to the END of SINGLE and DOUBLE line strings

Separating a column using big spaces in strings in R