0

Cuando el usuario da click en un botón ese botón se oculta y otros dos aparecen. Cuando aparecen el usuario debe elegir entre cualquiera de esos dos, al dar click en alguno de ellos aparece una imagen durante 3 segundos y se reinicia (vuelve a ocultarse la imagen, y los últimos dos botones). Quiero registrar el tiempo entre la aparición los dos botones y cuando el usuario de click en cualquiera de ellos. Cree este código para medir el tiempo

 Public Inicio_eleccion As Integer '
    Function Iniciar_ch() '
        Inicio_eleccion = Environment.TickCount '
        Return Inicio_eleccion
    End Function
    Public Duracion_ch As Integer '
    Function Total_desicion() '
        Duracion_ch = Environment.TickCount '
        Return (Duracion_ch - Inicio_eleccion)
    End Function

Hice tambien la subrutina del cambio en el que inicio el conteo del tiempo cuando se da click al boton

 Private Sub Boton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Boton1.Click
        cambio()
       

    End Sub

    Sub cambio()
        Iniciar_tiempo()
        Boton2.Enabled = True
        Boton2.Visible = True
        Boton3.Visible = True
        Boton3.Enabled = True
        Boton1.Visible = False



    End Sub

Y lo que sucede al dar click en los otros botones

 Private Sub Boton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Boton2.Click

        Reforzar()


    End Sub

    Private Sub Boton3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Boton3.Click

        Reforzar()



    End Sub
    Sub Reforzar()

        'Iniciar_Ref()

        Boton1.Visible = False
        Boton2.Visible = False
        Boton3.Visible = False
        Tom.Visible = True
        Do
            If Duración_Ref() > 3000 Then Exit Do
            My.Application.DoEvents()
        Loop
        Tom.Visible = False
        Boton1.Visible = True
        Boton2.Visible = False
        Boton3.Visible = False
        Total_desicion()
        TxT.WriteLine( Duración de la elección:" & Duracion_ch)-----*
        Cerrartxt()
        Me.Close()





    End Sub

Quiero registrar el tiempo en un archivo de texto que ya cree pero al correr el programa marca error donde está el asterisco. Les agradecería muchisimo si me ayudaran a encontrar el error.

1 respuesta 1

0

Las Funciones Necesitan Especificar el Delegado y los Parámetros, y a las Variables Asignar-les un Valor por defecto...

Así Debes Escribir las Funciones ( Public o Private ) y Asignar los Valores de Retorno...

Public Inicio_eleccion As Integer = 0 '
Public Function Iniciar_ch() As Integer '
    Inicio_eleccion = Environment.TickCount '
    Return Inicio_eleccion
End Function

Public Duracion_ch As Integer = 0 '
Public Function Total_desicion() As Integer '
    Duracion_ch = Environment.TickCount '
    Return (Duracion_ch - Inicio_eleccion)
End Function

También tienes errores en las subrutinas de el tercer ejemplo.

TxT.WriteLine( "Duración de la elección: " & Duracion_ch ) ' Línea de error

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.