Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
calcolo bmi - Form1.frm

Form1.frm

Caricato da: Albertking82
Scarica il programma completo

  1. Dim altezza As Integer
  2. Dim peso As Integer
  3. Dim b As Single
  4. Sub init()
  5. Txtpeso.Text = ""
  6. Txtalt.Text = ""
  7. Txtpeso.SetFocus
  8. Label3.Visible = False
  9. altezza = 0
  10. peso = 0
  11. b = 0
  12. End Sub
  13. Public Function calcola(p As Integer, a As Integer) As Single
  14.  Dim pes As Integer, alt As Single, al As Single
  15.  pes = Int(Txtpeso.Text)
  16.  al = a / 100
  17.  alt = al ^ 2
  18.  calcola = p / alt
  19. End Function
  20. Private Sub Cmdbmi_Click()
  21.  If Txtpeso.Text <> "" And Txtalt.Text <> "" Then
  22.   peso = Int(Txtpeso.Text)
  23.   altezza = Int(Txtalt.Text)
  24.   If altezza > 250 Then
  25.    MsgBox "Dai che non sei cosi alto!!!", vbInformation, "Info"
  26.    Call init
  27.    Exit Sub
  28.   End If
  29.    If peso > 400 Then
  30.     MsgBox "Pesi troppo", vbInformation, "Info"
  31.     Call init
  32.     Exit Sub
  33.    End If
  34.   b = calcola(peso, altezza)
  35.   Label3.Visible = True
  36.  If b < 18.5 Then
  37.     Label3.Caption = "Sei sottopeso"
  38.  End If
  39.   If b >= 18.5 And b <= 25 Then
  40.     Label3.Caption = "Sei normopeso"
  41.   End If
  42.    If b > 25 And b <= 30 Then
  43.     Label3.Caption = "Sei in sovrappeso"
  44.    End If
  45.    If b > 30 And b <= 40 Then
  46.     Label3.Caption = "Sei obeso"
  47.    End If
  48.    If b > 45 Then
  49.     Label3.Caption = "Sei obeso grave"
  50.    End If
  51.  End If
  52. End Sub
  53.  
  54. Private Sub Cmdres_Click()
  55. Call init
  56. End Sub
  57. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  58. Dim ris As Integer
  59.  ris = MsgBox("Sei sicuro di uscire?", vbQuestion + vbYesNoCancel, "Esci")
  60.   If ris = vbYes Then
  61.   MsgBox "Programma creato da Albertking82!", vbInformation, "Albertking82"
  62.    End
  63.   Else
  64.    Cancel = True
  65.   End If
  66. End Sub
  67.  
  68. Private Sub Txtalt_Change()
  69.  If Txtalt.Text <> "" Then
  70.   If Not IsNumeric(Txtalt.Text) Then
  71.    Txtalt.Text = ""
  72.   End If
  73.  End If
  74. End Sub
  75.  
  76. Private Sub Txtalt_KeyDown(KeyCode As Integer, Shift As Integer)
  77.  If KeyCode = 188 Or KeyCode = 190 Then
  78.   Txtalt.Text = ""
  79.  End If
  80. End Sub
  81.  
  82. Private Sub Txtpeso_Change()
  83.  If Txtpeso.Text <> "" Then
  84.   If Not IsNumeric(Txtpeso.Text) Then
  85.    Txtpeso.Text = ""
  86.   End If
  87.  End If
  88. End Sub
  89.  
  90. Private Sub Txtpeso_KeyDown(KeyCode As Integer, Shift As Integer)
  91.  If KeyCode = 188 Or KeyCode = 190 Then
  92.   Txtpeso.Text = ""
  93.  End If
  94. End Sub