IF Y IF ANIDADO

Private Sub CommandButton1_Click()
TextBox5.Text = Val(TextBox3.Text) * Val(TextBox4.Text)

If Val(TextBox5.Text) >= 4000 Then
TextBox6.Text = Val(TextBox5.Text) * 0.02
Else
TextBox6.Text = 0
End If
TextBox7.Text = Val(TextBox5.Text) - Val(TextBox6.Text)
End Sub
_________________________________________________________________________________

IF ANIDADO 

Private Sub CommandButton1_Click()

If Val(TextBox1.Text) = 1 Then
  TextBox2.Text = " HOY ES DIA LUNES"
Else
If Val(TextBox1.Text) = 2 Then
  TextBox2.Text = " HOY ES DIA MARTES"
Else
  If Val(TextBox1.Text) = 3 Then
  TextBox2.Text = " HOY DIA MIRCOLES"
Else
  If Val(TextBox1.Text) = 4 Then
  TextBox2.Text = " HOY DIA JUEVES"
  Else
  If Val(TextBox1.Text) = 5 Then
  TextBox2.Text = " HOY DIA VIERNES"
  Else
  If Val(TextBox1.Text) = 6 Then
  TextBox2.Text = " HOY DIA SABADO"
    Else
  If Val(TextBox1.Text) = 7 Then
  TextBox2.Text = " DOMINGO"
    Else
  TextBox2.Text = " ESE NUMERO DE DIA NO EXISTE INTENTE CON OTRO"

End If
End If
End If
End If
End If
End If
End If
End Sub


______________________________________________________________________________
USO DEL CASE EN VBA EXCEL 
Private Sub CommandButton1_Click()

Select Case TextBox1.Text
Case 1:
TextBox2.Text = " HOY ES DIA LUNES"
Case 2:
TextBox2.Text = " HOY ES DIA MARTES"
Case 3:
TextBox2.Text = " HOY ES DIA MIERCOLES"
Case 4:
 TextBox2.Text = "HOY ES DIA JUEVES"
Case 5:
 TextBox2.Text = " HOY ES DIA VIERNES"
Case 6:
 TextBox2.Text = " HOY ES DIA SABADO"
Case 7:
TextBox2.Text = " HOY ES DIA DOMINGO"
Case Else
TextBox2.Text = " ESE DIA NO EXISTE"
End Select
End Sub

Comentarios

Entradas populares de este blog

efecto hover