Advertisement
Guest User

code_vba_evandro

a guest
Oct 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub calc_imc()
  2.  
  3. 'Declaração de variáveis
  4. Dim altura As Double
  5. Dim peso As Double
  6. Dim imc As Double
  7.  
  8. Dim resultado As String
  9. Dim nome As String
  10.  
  11. 'Armazenar
  12. nome = "Evandro"
  13.  
  14. altura = 1.75
  15. peso = 67
  16.  
  17. 'Cálculo
  18. imc = peso / (altura * altura)
  19.  
  20. 'Verificar a faixa do IMC
  21. 'Sintaxe
  22. If imc < 18.5 Then
  23.     resultado = "Abaixo do peso"
  24. ElseIf imc <= 25 Then
  25.     resultado = "Peso ideal"
  26. ElseIf imc <= 30 Then
  27.     resultado = "Acima do peso"
  28. ElseIf imc <= 35 Then
  29.     resultado = "Obesidade"
  30. ElseIf imc <= 40 Then
  31.     resultado = "Obesidade severa"
  32. Else
  33.     resultado = "Obesidade mórbida"
  34. End If
  35.  
  36. '
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement