PDA

Ver la versión completa : Indicador de Masa Corporal



Arielo
19/09/2007, 08:23
Hola.
Aquí les traigo un programita utilitario.
Se trata de un indicador de masa corporal. Hecho con Visual Basic 6.0

Para ejecutarlo, lo que tienen que hacer, es copiar el código al bloc de notas (o cualquier procesador de textos), y grabar el archivo como "IMC.FRM"
Luego, desde Visual Basic, sólo tienen que agregar el form a un nuevo proyecto...



VERSION 5.00
Begin VB.Form Form1
BorderStyle = 3 'Fixed Dialog
Caption = "Indicador de masa corporal"
ClientHeight = 1470
ClientLeft = 45
ClientTop = 330
ClientWidth = 4920
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 98
ScaleMode = 3 'Pixel
ScaleWidth = 328
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "Calcular Otro"
Height = 525
Left = 1470
TabIndex = 11
Top = 2820
Width = 1605
End
Begin VB.CommandButton Command1
Caption = "Calcular"
Height = 525
Left = 2910
TabIndex = 4
Top = 510
Width = 1605
End
Begin VB.TextBox txtPeso
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 1538
TabIndex = 2
Text = "0"
Top = 840
Width = 1065
End
Begin VB.TextBox txtAltura
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 420
Left = 1538
TabIndex = 0
Text = "0"
Top = 240
Width = 1065
End
Begin VB.Label lblIndiceMay
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 435
Left = 3765
TabIndex = 8
Top = 1710
Width = 975
End
Begin VB.Label lblIndiceMen
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 435
Left = 2550
TabIndex = 6
Top = 1710
Width = 975
End
Begin VB.Label lblEtiqueta
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Diagnóstico:"
Height = 195
Index = 4
Left = 1575
TabIndex = 10
Top = 2340
Width = 885
End
Begin VB.Label lblEtiqueta
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "y"
Height = 195
Index = 3
Left = 3600
TabIndex = 9
Top = 1830
Width = 75
End
Begin VB.Label lblDiagnostico
Alignment = 2 'Center
Appearance = 0 'Flat
BackColor = &H80000005&
BeginProperty Font
Name = "MS Sans Serif"
Size = 13.5
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H80000008&
Height = 435
Left = 2550
TabIndex = 7
Top = 2220
Width = 2190
End
Begin VB.Label lblEtiqueta
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "El índice de masa corporal entre:"
Height = 195
Index = 2
Left = 120
TabIndex = 5
Top = 1830
Width = 2340
End
Begin VB.Label lblEtiqueta
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Peso:"
Height = 195
Index = 1
Left = 945
TabIndex = 3
Top = 900
Width = 405
End
Begin VB.Label lblEtiqueta
Alignment = 1 'Right Justify
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "Altura:"
Height = 195
Index = 0
Left = 945
TabIndex = 1
Top = 360
Width = 450
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Me.Height = 3780
difPeso = 0.01 ' Error estimado en la medición del Peso
difAltura = 0.5 ' Error estimado en la medición de la altura

Peso = Val(txtPeso.Text)
Altura = Val(txtAltura.Text)

Masa = (Peso / (Altura * Altura))
eMasa = (((difAltura / Altura) + ((difPeso / Peso) * 2)) * Masa)
IndMen = Masa - eMasa
lblIndiceMen = IndMen
lblIndiceMay = Masa

Select Case IndMen
Case Is < 18: lblDiagnostico = "Bajo Peso"
Case Is > 25: lblDiagnostico = "Sobrepeso"
Case Else: lblDiagnostico = "Peso Normal"
End Select
End Sub

Private Sub Command2_Click()
txtAltura.Text = 0
txtPeso.Text = 0
Me.Height = 1845
End Sub


La altura, debe ingresarse, por ejemplo, como: 1.85
Espero que les sirva de algo...
Saludos