title: Visual Basic If..Then..Else String statement
body: <p>My friend and I are working on a simple program for class that allows you to determine the payroll depending on if the string is set to <code>Processing</code> or <code>Sales</code>. We want it to determine that when you place <code>Sales</code> in a text box, it will calculate that with the hours you input. Sales is multiplied by 20.</p>
  
  <p>This is what we have at the moment.</p>
  
  <pre><code>Private Sub calcButton_Click(sender As Object, e As EventArgs) Handles calcButton.Click
  
          'declare
  
          Dim total As Double
  
          Dim weekly As Double
          Dim weekly1 As Double
          Dim weekly2 As Double
          Dim weekly3 As Double
          Dim weekly4 As Double
  
  
          Dim hours1 As Double
          Dim hours2 As Double
          Dim hours3 As Double
          Dim hours4 As Double
  
          Dim dep1 As Integer
          Dim dep2 As Integer
          Dim dep3 As Integer
          Dim dep4 As Integer
  
          Double.TryParse(hoursWorked1TB.Text, hours1)
          Double.TryParse(hoursworked2TB.Text, hours2)
          Double.TryParse(hoursWorked3TB.Text, hours3)
          Double.TryParse(hoursWorked4TB.Text, hours4)
  
  
          'as decimal
  
  
          weeklyPay1.Text = weekly.ToString("C1")
          weeklyPay2.Text = weekly.ToString("C1")
          weeklyPay3.Text = weekly.ToString("C1")
          weeklyPay4.Text = weekly.ToString("C1")
  
  
          'sales and processing
  
          If dep1TB.Text = "Sales" Then
              dep1 = 20
          ElseIf dep1TB.Text = "Processing" Then
              dep2 = 15
          Else : dep1 = 0
          End If
  
          If dep2TB.Text = "Sales" Then
              dep2 = 20
          ElseIf dep2TB.Text = "Processing" Then
              dep2 = 15
          Else : dep2 = 0
          End If
  
          If dep3TB.Text = "Sales" Then
              dep3 = 20
          ElseIf dep3TB.Text = "Processing" Then
              dep3 = 15
          Else : dep3 = 0
          End If
  
          If dep4TB.Text = "Sales" Then
              dep4 = 20
          ElseIf dep4TB.Text = "Processing" Then
              dep2 = 15
          Else : dep4 = 0
          End If
  
          'calculations
  
          weekly1 = hours1 * dep1
          weekly2 = hours2 * dep2
          weekly3 = hours3 * dep3
          weekly4 = hours4 * dep4
  
          total = weekly1 + weekly2 + weekly3 + weekly4
  
      End Sub
  </code></pre>
  
  <p>Later I determined that we need an As String variable, but everything still returns as 0.</p>