944,018 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Marked Solved
  • Views: 761
  • VB.NET RSS
Nov 3rd, 2009
0

Need to convert from string to integer

Expand Post »
How would I ask the user to input what type of engine they want and getting an output of $150

vb.net Syntax (Toggle Plain Text)
  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)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Light Poster
JRabbit2307 is offline Offline
32 posts
since Oct 2009
Nov 3rd, 2009
0
Re: Need to convert from string to integer
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...

VB Syntax (Toggle Plain Text)
  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; Nov 3rd, 2009 at 2:38 pm.
Reputation Points: 84
Solved Threads: 48
Posting Whiz
TomW is offline Offline
342 posts
since Sep 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: Keeping spaces when extracting text from HTML
Next Thread in VB.NET Forum Timeline: How to select a value in the database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC