Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 523
Cobold Avatar asked May 27 '11 10:05

Cobold


3 Answers

Dim input = Console.ReadLine()
Dim tokens As String() = input.Split(" ")
like image 82
aligray Avatar answered Oct 13 '22 01:10

aligray


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.

like image 33
Fredrik Mörk Avatar answered Oct 13 '22 01:10

Fredrik Mörk


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

Good luck.

like image 29
Akram Shahda Avatar answered Oct 13 '22 03:10

Akram Shahda