Jump to content

ajuda simples com váriavel (minhas primeiras =D)


tukith
 Share

Recommended Posts

galera, eu fiz 2 variaveis

dim parte2 as string

dim parte3 as string

sem elas o programa n funcionava, eu fiz elas e funcionou, é um programa de IMC (índice de massa corporal) até testei o resultado em sites e deu certo, mas aparece um erro depois que eu aperto calcular, eh o seguinte erro:

Run-time error '5':

Invalid procedure call or argument

como arrumo isso? valeu galera

Link to comment
Share on other sites

Dim parte2 As String
Dim parte3 As String

Private Sub Command1_Click()
If Val(resultado.Text) = Val(peso.Text) / (altura.Text) Then
resultado.Text = "15, Abaixo do Peso I."
Else
resultado.Text = "15 a 18.5, Abaixo do Peso"
End If
If parte2 Then
resultado.Text = "18.6 a 24.9, Peso Normal."
Else
resultado.Text = "25 a 29.9, Acima do Peso."
End If
If parte3 Then
resultado.Text = "30 a 39.9, Obesidade I."
Else
resultado.Text = "40 ou mais, Obesidade II."
End If
End Sub

Private Sub sair_Click()
    End
End Sub

Private Sub sobre_Click()
    Load Form2
    Unload Me
    Form2.Show
End Sub

Got it?

Link to comment
Share on other sites

primeiro nao percisas das variaveis que tens... "parte2 e parte3"

segundo estas a meter ao contrario, ou seja tens de meter o indice na condicao, ou seja,

If  peso.Text / altura.Text < 15 Then
resultado.Text = " Abaixo do Peso I."
Elseif peso.Text / altura.Text  <18.5 then
resultado.Text = " Abaixo do Peso"
Elseif peso.Text / altura.Text  <24.9 then
resultado.Text = " Peso Normal."
Elseif peso.Text / altura.Text  <29.9 then
resultado.Text = " Acima do Peso."
Elseif peso.Text / altura.Text  <39.9 then
resultado.Text = "30 a 39.9, Obesidade I."
Elseif peso.Text / altura.Text  >40 then
resultado.Text = " Obesidade II."
End If

supono que tenhas uma text box "resultado", "altura" e "peso"

Got it?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.