11 diciembre 2008

Otro convertidor


<html>

<head>

<title>ASPFacil - Código</title>



<%

'Recibimos los valores RGB

r = Request("r")

g = Request("g")

b = Request("b")

if r <> "" and g <> "" and b <> "" then



'Si los valores recibidos están entre 0 y 255, los convertimos a Hexadecimales

if ((0<=r) and (r<256)) and ((0<=g) and (g<256)) and ((0<=b) and (b<256)) then

r_hex = Hex(r)

g_hex = Hex(g)

b_hex = Hex(b)

'Si R, G o B son de sólo 1 dígito, anteponemos un 0 al Hexadecimal

IF len(r_hex)=1 then r_hex = "0" & r_hex

IF len(g_hex)=1 then g_hex = "0" & g_hex

IF len(b_hex)=1 then b_hex = "0" & b_hex

else

r_hex = "0"

g_hex = "0"

b_hex = "0"

end if



'Formamos la expresión hexadecimal (#000000)

codigo = "#" & r_hex & g_hex & b_hex

else

strError = "No se han introducido valores."

end if

%>

<CENTER>

<H2>Convertidor de Colores RGB-Hexadecimal</H2>

</CENTER>

<p><center>

<form method="post" action="rgb2hex.asp">

<table width="62%" border="1">

<tr>

<td width="34%" bgcolor="#CCCCCC">

<div align="center"><b>Color</b></div>

</td>

<td width="14%" bgcolor="#CCCCCC">

<div align="center"><b>Valor</b></div>

</td>

<td bgcolor="#CCCCCC" colspan="3">

<div align="center"><b>Muestra</b></div>

</td>

</tr>

<tr>

<td width="34%"><b>Rojo (Red)</b></td>

<td width="14%">

<input type="text" name="r" size="3" maxlength="3" value="<%=r%>">

</td>

<td rowspan="2" colspan="3" bgcolor="<%=codigo%>"> </td>

</tr>

<tr>

<td width="34%"><b>Verde (Green)</b></td>

<td width="14%">

<input type="text" name="g" size="3" maxlength="3" value="<%=g%>">

</td>

</tr>

<tr>

<td width="34%"><b>Azul (Blue)</b></td>

<td width="14%">

<input type="text" name="b" size="3" maxlength="3" value="<%=b%>">

</td>

<td width="19%"><b>Código</b></td>

<td width="33%"><%=codigo%></td>

</tr>

</table>

<table width="62%" border="0">

<tr>

<td width="100%" align="center" valign="middle">

<input type="submit" name="Submit" value="Convertir">

</td>

</tr>

</table>

</form>

<hr><br><br></center></p>

<p><%=strError%></p>

0 comentarios:

Publicar un comentario

Tu comentario ser� moderado la primera vez que lo hagas al igual que si incluyes enlaces. A partir de ahi no ser necesario si usas los mismos datos y mantienes la cordura. No se publicar�n insultos, difamaciones o faltas de respeto hacia los lectores y comentaristas de este blog.