Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #2238
| Newsgroups | comp.lang.basic.visual.misc |
|---|---|
| Date | 2015-02-11 19:23 -0800 |
| References | <b7f784f4-00a0-47ce-8874-72e236ec1735@googlegroups.com> <mbfsbo$jh8$1@speranza.aioe.org> |
| Message-ID | <a53f442d-3f65-4bbc-a523-2d87a71ea6d2@googlegroups.com> (permalink) |
| Subject | Re: how do you read in an integer in a console application? |
| From | G G <gdotone@gmail.com> |
> Assuming you mean VB.NET, try Console.ReadLine() and Integer.Parse()
********************************************************************************
' ----------- declare variable -----------
Dim stringToBeA_Number As String
Dim number1 As Integer
Dim number2 As Integer
Dim sum As Integer
'---------prompt user for input and read in first value --------
Console.WriteLine("Enter first value: ")
stringToBeA_Number = Console.ReadLine()
'-------- convert string to an integer and store in number1 -------
number1 = Integer.Parse( stringToBeA_Number )
'--------- convert string to an integer and store in number2 ------
Console.WriteLine("Enter first value: ")
stringToBeA_Number = Console.ReadLine()
'-------- convert string to number and store in number2 -------
number2 = Integer.Parse( stringToBeA_Number )
'------------- calculate sum -------------
sum = number1 + number2
'-------------- display sum ---------------
Console.WriteLine( "The sum is " + sum )
********************************************************************************
thanks Deanna, i hope that's right.
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how do you read in an integer in a console application? gdotone@gmail.com - 2015-02-11 06:13 -0800
Re: how do you read in an integer in a console application? G G <gdotone@gmail.com> - 2015-02-11 07:13 -0800
Re: how do you read in an integer in a console application? Deanna Earley <dee@earlsoft.co.uk> - 2015-02-11 15:24 +0000
Re: how do you read in an integer in a console application? G G <gdotone@gmail.com> - 2015-02-11 19:23 -0800
Re: how do you read in an integer in a console application? G G <gdotone@gmail.com> - 2015-02-11 19:28 -0800
csiph-web