943,752 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1895
  • VB.NET RSS
May 5th, 2008
0

BobCat Motors Solution

Expand Post »
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.

VB.NET Syntax (Toggle Plain Text)
  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?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
leroi green is offline Offline
93 posts
since Oct 2007
May 6th, 2008
0

Re: BobCat Motors Solution

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?
Reputation Points: 87
Solved Threads: 128
Practically a Master Poster
Oxiegen is offline Offline
652 posts
since Jun 2006
May 7th, 2008
0

Re: BobCat Motors Solution

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.
VB Syntax (Toggle Plain Text)
  1. Me.xFulltimeLabel.Text = "Full-Time: True"
Also you don't need to write "Me." infront because its already assumed that its like that.
Reputation Points: 10
Solved Threads: 8
Junior Poster
toko is offline Offline
104 posts
since Aug 2007

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: FileNotFoundException
Next Thread in VB.NET Forum Timeline: display output prompted by radio button





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


Follow us on Twitter


© 2011 DaniWeb® LLC