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.

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 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?

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?

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.

Me.xFulltimeLabel.Text = "Full-Time: True"

Also you don't need to write "Me." infront because its already assumed that its like that.

This article has been dead for over six months. Start a new discussion instead.