Cobold
Cobold

Reputation: 2613

Console read input

How to create a console application which would read input from user and assign the input to a variable? The problem is, I need to enter several words on one line separated with blank spaces like "ab cd efg" and then assign ab to one variable, cd to another variable and efg to another variable. Also the entered words can be any lenght.

Upvotes: 5

Views: 41985

Answers (3)

Akram Shahda
Akram Shahda

Reputation: 14781

You can use Console.Read, Console.ReadLine and String.Split methods to accomplish this task.

Good luck.

Upvotes: 1

aligray
aligray

Reputation: 2832

Dim input = Console.ReadLine()
Dim tokens As String() = input.Split(" ")

Upvotes: 14

Fredrik Mörk
Fredrik Mörk

Reputation: 158399

Is this homework? I'll keep the answer from being too concrete, but you will want to learn more about Console.ReadLine and String.Split. We can start there.

Upvotes: 2

Related Questions