•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 428,203 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,217 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser: Programming Forums
Views: 348 | Replies: 2
![]() |
•
•
Join Date: Oct 2007
Posts: 58
Reputation:
Rep Power: 2
Solved Threads: 0
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.
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?
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.
Private Sub xCalcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles xCalcButton.Click
'variables
Dim strInput As String = ""
Dim str1stCharacter As String = ""
Dim strlstCharacter As String
Dim strOutput As String = ""
Dim fullt As Integer = 0
Dim partt As Integer = 0
Dim newsellcar As Integer = 0
Dim usesellcar As Integer = 0
strInput = Me.xIdTextBox.Text
' changes the id number case to upper
strInput = Me.xIdTextBox.Text.ToUpper()
' sets the focus
Me.xIdTextBox.Focus()
str1stCharacter = Microsoft.VisualBasic.Left(strInput, 1)
strlstCharacter = Microsoft.VisualBasic.Left(strInput, 4)
If str1stCharacter = "F" And strlstCharacter = "1" Then
'salesperson is fulltime and sells new cars
Me.xFulltimeLabel.Text =
Me.xNewCarsLabel.Text = CStr(newsellcar)
ElseIf str1stCharacter = "F" And strlstCharacter = "2" Then
'salesperson is fulltime and sells used cars
Me.xFulltimeLabel.Text =
Me.xUsedCarsLabel.Text =
ElseIf str1stCharacter = "P" And strlstCharacter = "1" Then
'salesperson is part-time and sells new cars
Me.xParttimeLabel.Text =
Me.xNewCarsLabel.Text =
ElseIf str1stCharacter = "P" And strlstCharacter = "2" Then
'salesperson is part-time and sells used cars
Me.xParttimeLabel.Text =
Me.xUsedCarsLabel.Text =
End If
End SubI 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?
•
•
Join Date: Jun 2006
Location: Sweden
Posts: 45
Reputation:
Rep Power: 3
Solved Threads: 2
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.
What, exactly, is it that you want to do and you get stuck on?
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?
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.
Also you don't need to write "Me." infront because its already assumed that its like that.
VB Syntax (Toggle Plain Text)
Me.xFulltimeLabel.Text = "Full-Time: True"
Also you don't need to write "Me." infront because its already assumed that its like that.
![]() |
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: FileNotFoundException
- Next Thread: display output prompted by radio button


Linear Mode