• Viernes 10 de Mayo de 2024, 06:08

Autor Tema:  Problema Con El Boton Para Limpiar El Formulario  (Leído 1290 veces)

Baliam

  • Nuevo Miembro
  • *
  • Mensajes: 9
    • Ver Perfil
Problema Con El Boton Para Limpiar El Formulario
« en: Sábado 8 de Marzo de 2008, 06:18 »
0
Hola, apenas estoy iniciando con la programación en visual net, mi problema es que no he podido lograr que el botón para limpiar el formulario y se reinicie correctamente el programa, funcione. Les pido su ayuda, porfavor

Public Class Form1
    Dim hombre As String
    Dim mujer As String
    Dim pasado As String
    Dim ninio As String

    Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click
        End
    End Sub

    Private Sub CalcularToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calcular.Click

        If RadioButton1.Checked = True Then
            hombre = (Val(TextBox1.Text) * 100)
            mujer = hombre - 100
            ninio = mujer * 0.9
            Label3.Text = ninio & "kg"
            If Val(TextBox2.Text) > Val(Label3.Text) Then
                pasado = Val(TextBox2.Text) - Val(Label3.Text)
                TextBox3.Text = "Su peso esta pasado por " & pasado & "Kg"
            ElseIf Val(TextBox2.Text) = Val(Label3.Text) Then
                TextBox3.Text = "Felicidades su peso es el ideal"
            Else
                pasado = Val(Label3.Text) - Val(TextBox2.Text)
                TextBox3.Text = "Le faltan: " & pasado & "Kg"

            End If
        End If

        If RadioButton2.Checked = True Then
            hombre = (Val(TextBox1.Text) * 100)
            mujer = hombre - 100
            ninio = mujer * 0.85
            Label3.Text = ninio & "kg"
            If Val(TextBox2.Text) > Val(Label3.Text) Then
                pasado = Val(TextBox2.Text) - Val(Label3.Text)
                TextBox3.Text = "Su peso esta pasado por " & pasado & "Kg"
            ElseIf Val(TextBox2.Text) = Val(Label3.Text) Then
                TextBox3.Text = "Felicidades su peso es el ideal"
            Else
                pasado = Val(Label3.Text) - Val(TextBox2.Text)
                TextBox3.Text = "Le faltan: " & pasado & "Kg"
            End If
        End If
        Calcular.Enabled = False
    End Sub


    Private Sub GroupBox3_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox3.Enter
        If RadioButton1.Checked = False And RadioButton2.Checked = False Then
            Calcular.Enabled = False
            GroupBox3.Enabled = False
        End If
    End Sub



    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If RadioButton1.Checked = True Then
            NCalculo.Enabled = True
            GroupBox2.Enabled = False
            GroupBox3.Enabled = True
            Calcular.Enabled = False
            TextBox1.Focus()
        End If
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        If RadioButton2.Checked = True Then
            NCalculo.Enabled = True
            GroupBox2.Enabled = False
            GroupBox3.Enabled = True
            Calcular.Enabled = False
            TextBox1.Focus()
        End If
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = Chr(13) Then
            If TextBox1.Text = "" Then
                MsgBox("no capturo nada", MsgBoxStyle.Critical, "E r r o r")
            ElseIf Not IsNumeric(TextBox1.Text) Then
                MsgBox("Capture estatura en metros", MsgBoxStyle.Critical, "E r r o r")
                TextBox1.Text = ""
            ElseIf Val(TextBox1.Text) > 2.3 Then
                MsgBox("Ha superado el limite permitido", MsgBoxStyle.Critical, "E r r o r")
                TextBox1.Text = ""
                TextBox1.Focus()
            ElseIf IsNumeric(TextBox1.Text) Then
                TextBox1.Enabled = False
                TextBox1.Text = TextBox1.Text & "m"
                TextBox2.Enabled = True
                TextBox2.Focus()
            End If
        End If
    End Sub

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If e.KeyChar = Chr(13) Then
            TextBox2.Enabled = False
            TextBox2.Text = TextBox2.Text & "Kg"
            Calcular.Enabled = True
           
        End If
    End Sub

    Private Sub AcercaDeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AcercaDeToolStripMenuItem.Click
        Form2.Show()
    End Sub

    Private Sub NCalculo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NCalculo.Click
       




    End Sub
End Class

Baliam

  • Nuevo Miembro
  • *
  • Mensajes: 9
    • Ver Perfil
Re: Problema Con El Boton Para Limpiar El Formulario
« Respuesta #1 en: Viernes 14 de Marzo de 2008, 10:13 »
0
Bueno logre resolver el problema de una forma muy sencilla. Muchas gracias a lo que se tomaron la molestia de siquiera mirarlo.

Private Sub NCalculo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NCalculo.Click
       


        RadioButton1.Checked = False
        RadioButton2.Checked = False
        TextBox1.Enabled = True

        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        Label3.Text = ""
        GroupBox2.Enabled = True
        GroupBox3.Enabled = False

noVBice .NET

  • Nuevo Miembro
  • *
  • Mensajes: 10
    • Ver Perfil
Re: Problema Con El Boton Para Limpiar El Formulario
« Respuesta #2 en: Viernes 14 de Marzo de 2008, 22:16 »
0
Cita de: "Baliam"
Hola, apenas estoy iniciando con la programación en visual net, mi problema es que no he podido lograr que el botón para limpiar el formulario y se reinicie correctamente el programa, funcione. Les pido su ayuda, porfavor

Public Class Form1
    Dim hombre As String
    Dim mujer As String
    Dim pasado As String
    Dim ninio As String

    Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click
        End
    End Sub

    Private Sub CalcularToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Calcular.Click

        If RadioButton1.Checked = True Then
            hombre = (Val(TextBox1.Text) * 100)
            mujer = hombre - 100
            ninio = mujer * 0.9
            Label3.Text = ninio & "kg"
            If Val(TextBox2.Text) > Val(Label3.Text) Then
                pasado = Val(TextBox2.Text) - Val(Label3.Text)
                TextBox3.Text = "Su peso esta pasado por " & pasado & "Kg"
            ElseIf Val(TextBox2.Text) = Val(Label3.Text) Then
                TextBox3.Text = "Felicidades su peso es el ideal"
            Else
                pasado = Val(Label3.Text) - Val(TextBox2.Text)
                TextBox3.Text = "Le faltan: " & pasado & "Kg"

            End If
        End If

        If RadioButton2.Checked = True Then
            hombre = (Val(TextBox1.Text) * 100)
            mujer = hombre - 100
            ninio = mujer * 0.85
            Label3.Text = ninio & "kg"
            If Val(TextBox2.Text) > Val(Label3.Text) Then
                pasado = Val(TextBox2.Text) - Val(Label3.Text)
                TextBox3.Text = "Su peso esta pasado por " & pasado & "Kg"
            ElseIf Val(TextBox2.Text) = Val(Label3.Text) Then
                TextBox3.Text = "Felicidades su peso es el ideal"
            Else
                pasado = Val(Label3.Text) - Val(TextBox2.Text)
                TextBox3.Text = "Le faltan: " & pasado & "Kg"
            End If
        End If
        Calcular.Enabled = False
    End Sub


    Private Sub GroupBox3_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox3.Enter
        If RadioButton1.Checked = False And RadioButton2.Checked = False Then
            Calcular.Enabled = False
            GroupBox3.Enabled = False
        End If
    End Sub



    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        If RadioButton1.Checked = True Then
            NCalculo.Enabled = True
            GroupBox2.Enabled = False
            GroupBox3.Enabled = True
            Calcular.Enabled = False
            TextBox1.Focus()
        End If
    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        If RadioButton2.Checked = True Then
            NCalculo.Enabled = True
            GroupBox2.Enabled = False
            GroupBox3.Enabled = True
            Calcular.Enabled = False
            TextBox1.Focus()
        End If
    End Sub

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
        If e.KeyChar = Chr(13) Then
            If TextBox1.Text = "" Then
                MsgBox("no capturo nada", MsgBoxStyle.Critical, "E r r o r")
            ElseIf Not IsNumeric(TextBox1.Text) Then
                MsgBox("Capture estatura en metros", MsgBoxStyle.Critical, "E r r o r")
                TextBox1.Text = ""
            ElseIf Val(TextBox1.Text) > 2.3 Then
                MsgBox("Ha superado el limite permitido", MsgBoxStyle.Critical, "E r r o r")
                TextBox1.Text = ""
                TextBox1.Focus()
            ElseIf IsNumeric(TextBox1.Text) Then
                TextBox1.Enabled = False
                TextBox1.Text = TextBox1.Text & "m"
                TextBox2.Enabled = True
                TextBox2.Focus()
            End If
        End If
    End Sub

    Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
        If e.KeyChar = Chr(13) Then
            TextBox2.Enabled = False
            TextBox2.Text = TextBox2.Text & "Kg"
            Calcular.Enabled = True
           
        End If
    End Sub

    Private Sub AcercaDeToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AcercaDeToolStripMenuItem.Click
        Form2.Show()
    End Sub

    Private Sub NCalculo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NCalculo.Click
       




    End Sub
End Class
Que tal Baliam?

Estuve analizando tu progrma y no le veo funcion especifica al GroupBox2 y GroupBox3.

Otro es que de acuerdo a tu aplicacion no se si quieras usar "visbilbe" en vez de analbed?

Ej.:
GroupBox2.Visible = True ' o "False"

suerte