| | |
Console.Readline help
Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Sep 2008
Posts: 23
Reputation:
Solved Threads: 0
Hey,
Can anyone help me solve this, i am trying to read the value of Console.Readline into a varible declared as Double using vb 2008. As shown below:
I tried both coversion function above but got FormatException errors. Is there a way around this or can i use a different approach.
Can anyone help me solve this, i am trying to read the value of Console.Readline into a varible declared as Double using vb 2008. As shown below:
vbnet Syntax (Toggle Plain Text)
Private Sub ReadQuantity() ' Read ask customer to input many liters Private quantity As Double Console.Write("How many liters (only whole liters please ") "? ") Console.ReadLine() quantity = Double.Parse(Console.ReadLine()) quantity = Convert.ToDouble(Console.ReadLine())
Last edited by cscgal; Sep 13th, 2008 at 12:39 pm. Reason: Added code tags
•
•
Join Date: Jul 2008
Posts: 14
Reputation:
Solved Threads: 2
•
•
•
•
Hey,
Can anyone help me solve this, i am trying to read the value of Console.Readline into a varible declared as Double using vb 2008. As shown below:
Private Sub ReadQuantity()
' Read ask customer to input many liters
Private quantity As Double
Console.Write("How many liters (only whole liters please ") "? ")
Console.ReadLine()
quantity = Double.Parse(Console.ReadLine())
quantity = Convert.ToDouble(Console.ReadLine())
I tried both coversion function above but got FormatException errors. Is there a way around this or can i use a different approach.
Guess this is a conversion from string to double... so can you check "." or ","
Regards
•
•
Join Date: Jul 2008
Posts: 14
Reputation:
Solved Threads: 2
•
•
•
•
Thanks Dix,
But i'm not understanding what i should try,
and yes i am trying to do a conversion. Could you expand on your response please thanks.
Can you tell me what is your input?
eg :
dim input as string = console.readline()
if input has a "." and throw formatException then replace the "." by a ","
and if input has "," and throw formatException then replace "," by a "."
Let me know if it works.
Regards
vb Syntax (Toggle Plain Text)
Dim temp, quantity As Double Console.Write("How many liters (only whole liters please ) ? ") temp = Console.ReadLine() quantity = Double.Parse(temp)
Last edited by Jx_Man; Sep 12th, 2008 at 8:10 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
So, Please do something before post your thread.
* PM Asking will be ignored *
•
•
Join Date: Sep 2008
Posts: 23
Reputation:
Solved Threads: 0
My input is coming from:
Console.Write("How many liters (only whole liters please ") "? ")
I did not declare a string variable to store the input because i need it to be store as a Double for use in a calculation method. if that answer your ?
Do you know of a way i can Read an input line and some how change the returned value data type from String?
Console.Write("How many liters (only whole liters please ") "? ")
I did not declare a string variable to store the input because i need it to be store as a Double for use in a calculation method. if that answer your ?
Do you know of a way i can Read an input line and some how change the returned value data type from String?
•
•
Join Date: Jul 2008
Posts: 14
Reputation:
Solved Threads: 2
No...
what i meant is to retrieve your KEYBOARD INPUT
When you ask user to input how many liters
Just store the "CONSOLE.READLINE" in a STRING VARIABLE to check his content.
and then we can see why you have a formatexception when you did a convert.todouble.
Regards
what i meant is to retrieve your KEYBOARD INPUT
When you ask user to input how many liters
Just store the "CONSOLE.READLINE" in a STRING VARIABLE to check his content.
and then we can see why you have a formatexception when you did a convert.todouble.
Regards
Last edited by Dnx; Sep 12th, 2008 at 8:26 am.
![]() |
Similar Threads
- Printing from a console application (C#)
- how to use timer in console app (VB.NET)
- VB.Net experts: I need some help (VB.NET)
- hey guys; having some trouble with this program i'm writing (Java)
- Loop program help (C++)
- Trying to write a program that you can enter #s and multiply at the end. (Java)
- Return Length of a string? (C++)
Other Threads in the VB.NET Forum
- Previous Thread: Automatically type...?!
- Next Thread: Need help in placing icon for windows application
| Thread Tools | Search this Thread |
.net .net2005 30minutes 2005 2008 access account arithmetic array basic binary bing button buttons c# center check code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save savedialog searchbox searchvb.net select serial server soap sql table tcp text textbox timer toolbox trim update updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf






