TEMA 10: Programa Control Label
1. Programa: vamos a realizar un programa para utilizar el control Label. En primer lugar dibujamos el Formulario con sus controles y asignamos las propiedades a estos. En el apartado OBJETO aparecerá el control con el nombre que debe tener en su propiedad Name. Una vez que tenemos esto, escribimos el código.
| OBJETO | PROPIEDAD | VALOR |
| Form1 | BorderStyle Caption |
1 Prueba del control Etiqueta |
| LblEtiqueta | BorderStyle Caption |
1 Texto de prueba |
| CmdArial | Caption | Arial |
| CmdTimes | Caption | Times New |
| CmdComic | Caption | Comic Sans |
| CmdNegrita | Caption | Negrita |
| CmdCursiva | Caption | Cursiva |
| CmdSubrayado | Caption | Subrayado |
| CmdMas | Caption | Más tamaño |
| CmdMenos | Caption | Menos tamaño |
| CmdSalir | Caption | Salir |
Private Sub CmdArial_Click()
LblEtiqueta.Font.Name = "Arial" 'Tipo de letra Arial
End Sub
Private Sub CmdComic_Click()
LblEtiqueta.Font.Name = "Comic Sans MS" 'Tipo de letra Comic Sans MS
End Sub
Private Sub CmdCursiva_Click()
LblEtiqueta.Font.Italic = Not LblEtiqueta.Font.Italic 'Activar/desactivar cursiva
End Sub
Private Sub CmdMas_Click()
LblEtiqueta.Font.Size = LblEtiqueta.Font.Size + 2 'Aumenta tamaño
If LblEtiqueta.Font.Size > 22 Then LblEtiqueta.Font.Size = 22
End Sub
Private Sub CmdMenos_Click()
LblEtiqueta.Font.Size = LblEtiqueta.Font.Size - 2 'Disminuye tamaño
If LblEtiqueta.Font.Size < 8 Then LblEtiqueta.Font.Size = 8
End Sub
Private Sub CmdNegrita_Click()
LblEtiqueta.Font.Bold = Not LblEtiqueta.Font.Bold 'Activar/desactivar negrita
End Sub
Private Sub CmdSalir_Click()
End 'Salir del programa
End Sub
Private Sub CmdSubrayado_Click() 'Activar/desactivar
LblEtiqueta.Font.Underline = Not LblEtiqueta.Font.Underline 'subrayado
End Sub
Private Sub CmdTimes_Click()
LblEtiqueta.Font.Name = "Times New Roman" 'Letra Times New Roman
End Sub