Programación VB, ¿variables personalizadas para lograr color? Por favor dame un consejo
De hecho, este problema es muy simple, pero los tres colores deben ingresarse en tres cuadros de texto (controles de matriz) respectivamente, configurar rojo, verde y azul, y configurar el color de Texto2 en el Evento Text1_Change del cuadro de texto. Private?Sub?Form_Load()
Text2.Text?=?"¿Cómo estás?"
Text2.FontSize?=?20
Text2.FontBold ?=?Verdadero
Fin?Sub
Privado?Sub?Text1_Change(Index?As?Integer)
Dim?AA?As?Integer,?BB ?As?String
AA?=?Index
Si?AA?=?0?Entonces?BB?=?"Red"
Si?AA ?=?1?Entonces?BB?=?"Verde"
Si?AA?=?2?Entonces?BB?=?"Azul"
Si?EsNumeric( Texto1 (AA).Text)?=?False?Then
MsgBox?"El "?&?BB?&?" que ingresaste no es un número. Los valores de varios colores deben estar entre 0 -255 Entero positivo! "
Texto1(AA).Texto?=?""
Texto1(AA).SetFocus
Salir?Sub
Fin?Si
Si?Val(Texto1(AA).Texto)?0?O?Val(Texto1(AA).Texto)?>?255?Entonces
MsgBox?"El número "?&?BB?&?" que ingresaste es incorrecto. ¡No puede ser menor que 0 ni mayor que 255!"
Text1(AA).Text?= ?""
Texto1(AA).SetFocus
Salir?Sub
Fin?Si
Si?Val(Texto1(0) ).Texto )?>=?0?Y?Val(Texto1(0).Texto)?<=?255?Y?Val(Texto1(1).Texto)?>=?0?Y?Val(Texto1( 1). ¿Texto)?<=?255?Y?Val(Texto1(2).Texto)?>=?0?Y?Val(Texto1(2).Texto)?<=?255?Entonces
Text2.ForeColor?=?RGB(Val(Text1(0).Text),?Val(Text1(1).Text),?Val(Text1(2).Text))
¿Fin?Si
Fin?Sub