BobCat Motors Solution

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

Join Date: Oct 2007
Posts: 89
Reputation: leroi green is an unknown quantity at this point 
Solved Threads: 0
leroi green leroi green is offline Offline
Junior Poster in Training

BobCat Motors Solution

 
0
  #1
May 5th, 2008
hey all. the program is for Chapter 8 Lesson C in the Visual Basic 2005

below is code where i have to create a program that allows the user to enter a 4-digit number that identifies whether the salesperson is full or part time.

"Each salesperson at BobCat Motors is assigned an ID number, which consists of four characters. The first character is either the letter F or the letter P. The letter F indicates that the salesperson is a full-time employee. The letter P indicates that he or she is a part-time employee. The middle two characters are the salesperson's initials, and the last character is either a 1 or a 2. A 1 indicates that the salesperson sells new cars, and a 2 indicates that the salesperson sells used cars.

  1. Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click
  2. 'variables
  3. Dim strInput As String = ""
  4.  
  5. Dim str1stCharacter As String = ""
  6. Dim strlstCharacter As String
  7.  
  8. Dim strOutput As String = ""
  9.  
  10. Dim fullt As Integer = 0
  11. Dim partt As Integer = 0
  12. Dim newsellcar As Integer = 0
  13. Dim usesellcar As Integer = 0
  14.  
  15. strInput = Me.xIdTextBox.Text
  16.  
  17. ' changes the id number case to upper
  18. strInput = Me.xIdTextBox.Text.ToUpper()
  19. ' sets the focus
  20. Me.xIdTextBox.Focus()
  21.  
  22. str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1)
  23. strlstCharacter = Microsoft.VisualBasic.Left(strInput, 4)
  24.  
  25. If str1stCharacter = "F" And strlstCharacter = "1" Then
  26. 'salesperson is fulltime and sells new cars
  27. Me.xFulltimeLabel.Text =
  28. Me.xNewCarsLabel.Text = CStr(newsellcar)
  29. ElseIf str1stCharacter = "F" And strlstCharacter = "2" Then
  30. 'salesperson is fulltime and sells used cars
  31. Me.xFulltimeLabel.Text =
  32. Me.xUsedCarsLabel.Text =
  33. ElseIf str1stCharacter = "P" And strlstCharacter = "1" Then
  34. 'salesperson is part-time and sells new cars
  35. Me.xParttimeLabel.Text =
  36. Me.xNewCarsLabel.Text =
  37.  
  38. ElseIf str1stCharacter = "P" And strlstCharacter = "2" Then
  39. 'salesperson is part-time and sells used cars
  40. Me.xParttimeLabel.Text =
  41. Me.xUsedCarsLabel.Text =
  42.  
  43. End If
  44.  
  45.  
  46. End Sub

I know what I want to do...just kinda stuck on making it happen. I'm thinking I may need a Do While structure for the F and P but iono.

Help?
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 53
Reputation: Oxiegen is an unknown quantity at this point 
Solved Threads: 3
Oxiegen Oxiegen is offline Offline
Junior Poster in Training

Re: BobCat Motors Solution

 
0
  #2
May 6th, 2008
The code looks valid and it's gonna do what it's supposed to.
You don't need a Do While.

This snippet extracts the first and last character of the string which is then used in the IF statement for comparison.
str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1) strlstCharacter = Microsoft.VisualBasic.Left(strInput, 4)
What, exactly, is it that you want to do and you get stuck on?
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 89
Reputation: toko is an unknown quantity at this point 
Solved Threads: 8
toko's Avatar
toko toko is offline Offline
Junior Poster in Training

Re: BobCat Motors Solution

 
0
  #3
May 7th, 2008
Like Oxiegen said, it should run perfectly but don't forget to finish the IF statement and fill the equal sign to do what it should ie.
  1. Me.xFulltimeLabel.Text = "Full-Time: True"
Also you don't need to write "Me." infront because its already assumed that its like that.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC