Visual Basic: Forms, Timers and Array Examples

Classified in Technology

Written on in English with a size of 2.54 KB

Visual Basic Forms and Console Code Examples

The following corrected Visual Basic code preserves the original content while fixing spelling, capitalization, and minor structural issues for clarity.

If RadioButton1.Checked Then
    MsgBox("Eligió viajar por " & RadioButton1.Text)
End If

Private Sub Form1_Load(...)
    Combocargo.Items.Add("gerente")
End Sub

Private Sub Combocargo_SelectedIndexChanged(...)
    Select Case Combocargo.SelectedIndex
        Case 0
            Me.TextBox1.Text = 6200
    End Select
End Sub

Private Sub Button1_Click(...)
    Combocargo.Items.Add(TextBox1.Text)
End Sub

Private Sub Button2_Click(...)
    Combocargo.Items.Remove(Combocargo.SelectedItem)
End Sub

Module Module1
    Sub Main()
        Dim v(4) As Integer
        Dim suma As Integer
        Dim promedio As Double
        For i = 0 To 4
            Console.WriteLine("Digite la calificación de la posición " & i)
            v(i) = Console.ReadLine
        Next
        For i = 0 To 4
            suma = suma + v(i)
            promedio = suma / 5
        Next
        Console.WriteLine("La suma de la calificación es " & suma)
        Console.WriteLine("El promedio es " & promedio)
        Console.ReadLine()
    End Sub
End Module

Private Sub Timer1_Tick(...)
    Label1.Text = "Cerrar sesión"
    Timer1.Stop()
    Timer2.Start()
End Sub

Private Sub Timer2_Tick(...)
    Label1.Text = "Cerrando aplicación"
    Timer2.Stop()
    Timer3.Start()
End Sub

Private Sub Timer3_Tick(...)
    Label1.Visible = False
End Sub

Private Sub Button1_Click(...)
    Timer1.Start()
End Sub

Public Class Form1
    Private Sub Button1_Click(...)
        Dim datos(0 To 1000) As Integer
        Dim n As Integer
        Dim suma As Integer
        Dim promedio As Double
        n = Convert.ToInt16(Me.TextBox1.Text)
        For i = 0 To n
            datos(i) = InputBox("numero" & i)
            suma = suma + datos(i)
        Next
        promedio = suma / (n + 1)
        Me.TextBox2.Text = promedio
        For i = 0 To n
            If datos(i) > promedio Then
                ListBox1.Items.Add(datos(i))
            End If
        Next
    End Sub
End Class

Notes: Spelling and accent corrections were applied to Spanish strings (for example, "Eligió", "calificación", "Cerrar sesión"). VB keywords were capitalized for consistency (If, Then, End If, Private Sub, End Sub, Module, End Module). Structural corrections include adding missing End If where appropriate and ensuring each Sub has a matching End Sub.

Related entries: