Sei sulla pagina 1di 5

Crear un formulario como el que se muestra a

continuacin que, mediante controles Radio Button,


permita cambiar
los colores del bandern.

Los Radio Button estn contenidos en Group Box y los


nombres (propiedad Name) de cada uno de ellos son:
radRojo,
radBlanco, radVerde,radAmarillo, radAzul, radNegro

CODIGO FUENTE
Class: Declara el nombre de una clase, as como una
definicin de las variables, propiedades, eventos y
mtodos que
la componen.
#Region: Contrae y oculta secciones de cdigo en
archivos de Visual Basic .NET.
En el ejemplo siguiente se utiliza la directiva #Region.
#Region "MathFunctions"

' Insert code for the Math functions here.


#End Region
Al utilizar el diseador de formularios, el Visual
Basic.NET genera el cdigo de las operaciones
realizadas:
Public Class Ej01_01
Inherits System.Windows.Forms.Form
#Region " Cdigo generado por el Diseador de
Windows Forms "

#End Region
Finalizado el diseo se debe programar la lgica
operacional de respuesta a cada uno de los eventos que
ocurran:
Private Sub radRojo_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
radRojo.CheckedChanged
lblTop.BackColor = System.Drawing.Color.Red
End Sub
Private Sub radBlanco_CheckedChanged(ByVal sender

As System.Object, ByVal e As System.EventArgs)


Handles
radBlanco.CheckedChanged
lblTop.BackColor = System.Drawing.Color.White
End Sub
Private Sub radVerde_CheckedChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles
radVerde.CheckedChanged
lblLeft.BackColor = System.Drawing.Color.Lime
End Sub
Private Sub radAmarillo_CheckedChanged(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles
radAmarillo.CheckedChanged
lblLeft.BackColor = System.Drawing.Color.Yellow
End Sub
Private Sub radAzul_CheckedChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
radAzul.CheckedChanged
lblRight.BackColor = System.Drawing.Color.Blue

End Sub
Private Sub radNegro_CheckedChanged(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles
radNegro.CheckedChanged
lblRight.BackColor = System.Drawing.Color.Black
End Sub
Private Sub btnSalir_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSalir.Click
Me.Close()
End Sub
Private Sub btnSinColor_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
btnSinColor.Click
lblTop.BackColor = System.Drawing.Color.White
lblLeft.BackColor = System.Drawing.Color.White
lblRight.BackColor = System.Drawing.Color.White
End Sub
Private Sub Ej01_01_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
MyBase.Load
lblTop.BackColor = System.Drawing.Color.White

lblMid.BackColor = System.Drawing.Color.White
lblLeft.BackColor = System.Drawing.Color.White
lblRight.BackColor = System.Drawing.Color.White
End Sub
End Class