So I'm new to programming and currently, I'm creating a school project with Visual Basic and .NET, I know that I might either have a problem with formatting or converting or assigning a value(which I don't know how to do) but whatever I try the multiplied result always gives me 0, (Salarybox is the "RichTextBox" I'm using to put the result in)

Private Sub Guna2Button1_Click(sender As Object, e As EventArgs) Handles Guna2Button1.Click
        Dim DailyPay As Integer


        If empposition.Text = "" Then
            MsgBox("Select an Employee")
        ElseIf wdays.Text = "" Or Integer.Parse(wdays.Text) > 28 Then
            MsgBox("Enter a valid Number of Days")
        Else
            If empposition.Text = "Receptionist" Then
                DailyPay = 1200
            ElseIf empposition.Text = "Reception manager" Then
                DailyPay = 1500
            ElseIf empposition.Text = "House keeping manager" Then
                DailyPay = 700
            ElseIf empposition.Text = "Bar manager" Then
                DailyPay = 1500
            ElseIf empposition.Text = "Barman" Then
                DailyPay = 850
            ElseIf empposition.Text = "Waiter" Then
                DailyPay = 550
            ElseIf empposition.Text = "Vendor" Then
                DailyPay = 800
            ElseIf empposition.Text = "Shop manager" Then
                DailyPay = 1500
            ElseIf empposition.Text = "IT manager" Then
                DailyPay = 1500
            ElseIf empposition.Text = "Technicien" Then
                DailyPay = 1000
            ElseIf empposition.Text = "Spa manager" Then
                DailyPay = 1200
            ElseIf empposition.Text = "Beautician" Then
                DailyPay = 800
            ElseIf empposition.Text = "Security man" Then
                DailyPay = 500
            End If
            Dim total As Integer = DailyPay * Integer.Parse(wdays.Text)
            Salarybox.Text = "Employee ID:   " & empid.Text & vbLf & "Employee Name:   " & ename.Text & vbLf & "Employee LastName:   " & lastname.Text & vbLf & "Position:   " & empposition.Text & vbLf & "Worked Days:   " & wdays.Text & vbLf & "Daily Salary:   " & DailyPay & vbLf & "Total Amount:   " & total

        End If
    End Sub

Have you tried setting a breakpoint in your handler and stepping through the code?

commented: No I didn't because it didn't get mentioned in any of the solutions I found, If It's necessary, in which line of the code I should set the breakpoint +0

As to where to break, line 40 because I can mouse over every variable and string to see what could be wrong.

commented: Okay I did it, but what comes after? +0

Sorry but I should have written "YOU can mouse every variable and string to see what is wrong."

This is classic debugging skill. It can be hard the first time but gets easier.

commented: Okay, so I did that and it says that in Integer.Parse(wdays.Text):ArgumentNullException/FormatingException/OverflowException +0

thanks for sharing awesome knowledge . I get same knowledge by other forums platform. thanks again

What does wdays.Text contain?

commented: it's the textbox that I'm writing the number of days in. (Integers) +0

So you found DailyPay is zero. While at the breakpoint find out why by moving the mouse point over empposition.Text to see if you ever had a match. Tip: I would have added one more else to cover where there was no match for the empposition.

Remember this isn't the only issue I see in said code. For example, numbers may need to be converted to text strings before being used for Salary.Text. I won't have this version of VB.net so I leave that for you to explore.

commented: Thank you, well I did that and it returned the last else value which means the problem is in the if else statement,but I still can't see what it is +0

Remember I'm not there to see what you see and if I do help you find ONE issue, there can be more.

-> empposition.Text should be a text box's text. Since DailyPay is zero my bet is the text never matched in all those if's. Only you can examine this area.

commented: Exactly, turned out the text is not matching the text in "If statements" cuz of some added space, Thank you +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.