Need to convert from string to integer

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Oct 2009
Posts: 32
Reputation: JRabbit2307 is an unknown quantity at this point 
Solved Threads: 0
JRabbit2307 JRabbit2307 is offline Offline
Light Poster

Need to convert from string to integer

 
0
  #1
22 Days Ago
How would I ask the user to input what type of engine they want and getting an output of $150

  1. Console.WriteLine("Enter EngineChoice for your vehicle:")
  2. Response = Console.ReadLine()
  3. EngineChoice = Convert.ToString(Response)
  4.  
  5. If EngineChoice = Sixcylinder Then
  6. Convert.ToInt32(Response)
  7. Console.WriteLine(150)
  8. ElseIf EngineChoice = Eightcylinder Then
  9. Console.WriteLine(475)
  10. ElseIf EngineChoice = Diesel Then
  11. Console.WriteLine(750)
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 286
Reputation: TomW is on a distinguished road 
Solved Threads: 37
TomW TomW is offline Offline
Posting Whiz in Training
 
0
  #2
22 Days Ago
This is a console app or is that just for your example? If a console app, I would start by displaying a list of the choices they have to pick from with an item/row number starting each line and then asking for them to type that item/row number in for the input. Also remember what is read/written is already text even if there writing a number...

  1. Dim strEngineChoice As String = ""
  2.  
  3. Console.WriteLine("Enter 1 for six cylinder")
  4. Console.WriteLine("Enter 2 for eight cylinder")
  5. Console.WriteLine("Enter 3 for disel")
  6.  
  7. strEngineChoice = Console.ReadLine
  8.  
  9. Select Case strEngineChoice
  10. Case "1"
  11. Console.WriteLine("Price : $150")
  12. Case "2"
  13. Console.WriteLine("Price : $475")
  14. Case "3"
  15. Console.WriteLine("Price : $750")
  16. Case Else
  17. Console.WriteLine("Invalid selection")
  18. End Select
Last edited by TomW; 22 Days Ago at 2:38 pm.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC