Posteado por: irodriguezm | abril 28, 2010

CALENDARIO EN VISUAL STUDIO 2008

 

Hoy me dieron un trabajo en la U y por simple que sea me gustaria compartirlo con ustedes, se trata de lo siguiente: 

 usando la propiedad calendar, al ingresar la fecha de nacimiento y calcular el signo del zodiaco y el signo en el horoscopo chino. 

vamos por parte, lo primero es crear un nuevo sitio web, en mi caso use visual basic. luego nos vamos al cuadro de herramientas  y agregamos un objeto calendar. 

 

en mi caso use 4 textbox y 2 label para mostrar la información, buenos vamos al codigo de nuestra pagina Default.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Página sin título</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <p style="font-family: Verdana; background-color: #FFFFCC">
        <asp:Label ID="Label2" runat="server" Text="Label">Seleccione su fecha de nacimiento..</asp:Label>
            
        </p>
    <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999" 
            CellPadding="4" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" 
            ForeColor="Black" Height="180px" Width="200px">
        <SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
        <SelectorStyle BackColor="#CCCCCC" />
        <WeekendDayStyle BackColor="#FFFFCC" />
        <TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
        <OtherMonthDayStyle ForeColor="#808080" />
        <NextPrevStyle VerticalAlign="Bottom" />
        <DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
        <TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
        </asp:Calendar>
        <label style="font-family: Verdana; font-size: small">Fecha:</label><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" Visible="False"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server" Visible="False"></asp:TextBox>
        <asp:TextBox ID="TextBox4" runat="server" Visible="False"></asp:TextBox>
    </div>
    <p style="font-family: Verdana; background-color: #FFFFCC">
        <asp:Label ID="Label1" runat="server" Text="" Visible="false"></asp:Label>
    </p>
    <p style="font-family: Verdana; background-color: #FFFFCC">
    <asp:Label ID="Label3" runat="server" Text="" Visible="false"></asp:Label>
    </p>
    </form>
    
</body>
</html>

Ahora el codigo de Default.aspx.vb

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Calendar1.SelectionChanged
        TextBox1.Text = Calendar1.SelectedDate
        'extraer los 2 primeros valores 
        TextBox2.Text = Left$(TextBox1.Text, 2)
        'extraer desde el 4to registro los 2 valores sgtes 
        TextBox3.Text = Mid$(TextBox1.Text, 4, 2)
        TextBox4.Text = Mid$(TextBox1.Text, 7, 4)


        'Aries 21-03 - 20-04
        'Tauro 21-04 - 21-05
        'Geminis 22-05 - 21-06
        'Cancer 21-06 - 23-07
        'Leo 24-7 - 23-8
        'Virgo 24-8 - 23-9
        'Libra 24-9 - 23-10
        ' Escorpio (24/10 - 22/11)
        'Sagitario (23/11 - 21/12)
        'Capricornio (22/12 - 20/1)
        'Acuario (21/1 - 19/2)
        'Piscis (20/2 - 20/3)
        If ((TextBox4.Text = "1900") Or (TextBox4.Text = "1912") Or (TextBox4.Text = "1924") Or (TextBox4.Text = "1936") Or (TextBox4.Text = "1948") Or (TextBox4.Text = "1960") Or (TextBox4.Text = "1972") Or (TextBox4.Text = "1984") Or (TextBox4.Text = "1996") Or (TextBox4.Text = "2008")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Rata"


        ElseIf ((TextBox4.Text = "1901") Or (TextBox4.Text = "1913") Or (TextBox4.Text = "1925") Or (TextBox4.Text = "1937") Or (TextBox4.Text = "1949") Or (TextBox4.Text = "1961") Or (TextBox4.Text = "1973") Or (TextBox4.Text = "1985") Or (TextBox4.Text = "1997") Or (TextBox4.Text = "2009")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Buey"

        ElseIf ((TextBox4.Text = "1902") Or (TextBox4.Text = "1914") Or (TextBox4.Text = "1926") Or (TextBox4.Text = "1938") Or (TextBox4.Text = "1950") Or (TextBox4.Text = "1962") Or (TextBox4.Text = "1974") Or (TextBox4.Text = "1986") Or (TextBox4.Text = "1998") Or (TextBox4.Text = "2010")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Tigre"

        ElseIf ((TextBox4.Text = "1903") Or (TextBox4.Text = "1915") Or (TextBox4.Text = "1927") Or (TextBox4.Text = "1939") Or (TextBox4.Text = "1951") Or (TextBox4.Text = "1963") Or (TextBox4.Text = "1975") Or (TextBox4.Text = "1987") Or (TextBox4.Text = "1999")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Conejo"

        ElseIf ((TextBox4.Text = "1904") Or (TextBox4.Text = "1916") Or (TextBox4.Text = "1928") Or (TextBox4.Text = "1940") Or (TextBox4.Text = "1952") Or (TextBox4.Text = "1964") Or (TextBox4.Text = "1976") Or (TextBox4.Text = "1988") Or (TextBox4.Text = "2000")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Dragón"

        ElseIf ((TextBox4.Text = "1905") Or (TextBox4.Text = "1917") Or (TextBox4.Text = "1929") Or (TextBox4.Text = "1941") Or (TextBox4.Text = "1953") Or (TextBox4.Text = "1965") Or (TextBox4.Text = "1977") Or (TextBox4.Text = "1989") Or (TextBox4.Text = "2001")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Serpiente"

        ElseIf ((TextBox4.Text = "1906") Or (TextBox4.Text = "1918") Or (TextBox4.Text = "1930") Or (TextBox4.Text = "1942") Or (TextBox4.Text = "1954") Or (TextBox4.Text = "1966") Or (TextBox4.Text = "1978") Or (TextBox4.Text = "1990") Or (TextBox4.Text = "2002")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Caballo"

        ElseIf ((TextBox4.Text = "1907") Or (TextBox4.Text = "1919") Or (TextBox4.Text = "1931") Or (TextBox4.Text = "1943") Or (TextBox4.Text = "1955") Or (TextBox4.Text = "1967") Or (TextBox4.Text = "1979") Or (TextBox4.Text = "1991") Or (TextBox4.Text = "2003")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Cabra"

        ElseIf ((TextBox4.Text = "1908") Or (TextBox4.Text = "1920") Or (TextBox4.Text = "1932") Or (TextBox4.Text = "1944") Or (TextBox4.Text = "1956") Or (TextBox4.Text = "1968") Or (TextBox4.Text = "1980") Or (TextBox4.Text = "1992") Or (TextBox4.Text = "2004")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Mono"

        ElseIf ((TextBox4.Text = "1909") Or (TextBox4.Text = "1921") Or (TextBox4.Text = "1933") Or (TextBox4.Text = "1945") Or (TextBox4.Text = "1957") Or (TextBox4.Text = "1969") Or (TextBox4.Text = "1981") Or (TextBox4.Text = "1993") Or (TextBox4.Text = "2005")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Gallo"

        ElseIf ((TextBox4.Text = "1910") Or (TextBox4.Text = "1922") Or (TextBox4.Text = "1934") Or (TextBox4.Text = "1946") Or (TextBox4.Text = "1958") Or (TextBox4.Text = "1970") Or (TextBox4.Text = "1982") Or (TextBox4.Text = "1994") Or (TextBox4.Text = "2006")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Perro"

        ElseIf ((TextBox4.Text = "1911") Or (TextBox4.Text = "1923") Or (TextBox4.Text = "1935") Or (TextBox4.Text = "1947") Or (TextBox4.Text = "1959") Or (TextBox4.Text = "1971") Or (TextBox4.Text = "1983") Or (TextBox4.Text = "1995") Or (TextBox4.Text = "2007")) Then
            Me.Label3.Visible = "True"
            Label3.Text = ""
            Label3.Text = "Horóscopo chino: Cerdo"

        End If

        
        If ((TextBox3.Text = "03" And TextBox2.Text >= "21") Or (TextBox3.Text = "04" And TextBox2.Text <= "20")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Aries"
        ElseIf ((TextBox3.Text = "04" And TextBox2.Text >= "21") Or (TextBox3.Text = "05" And TextBox2.Text <= "21")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Tauro"
        ElseIf ((TextBox3.Text = "05" And TextBox2.Text >= "22") Or (TextBox3.Text = "06" And TextBox2.Text <= "21")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Geminis"
        ElseIf ((TextBox3.Text = "06" And TextBox2.Text >= "21") Or (TextBox3.Text = "07" And TextBox2.Text <= "23")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Cancer"
        ElseIf ((TextBox3.Text = "07" And TextBox2.Text >= "24") Or (TextBox3.Text = "08" And TextBox2.Text <= "23")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Leo"
        ElseIf ((TextBox3.Text = "08" And TextBox2.Text >= "24") Or (TextBox3.Text = "09" And TextBox2.Text <= "23")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Virgo"

        ElseIf ((TextBox3.Text = "09" And TextBox2.Text >= "24") Or (TextBox3.Text = "10" And TextBox2.Text <= "23")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Libra"

        ElseIf ((TextBox3.Text = "10" And TextBox2.Text >= "24") Or (TextBox3.Text = "11" And TextBox2.Text <= "22")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Escorpio"

        ElseIf ((TextBox3.Text = "11" And TextBox2.Text >= "23") Or (TextBox3.Text = "12" And TextBox2.Text <= "21")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Sagitario"

        ElseIf ((TextBox3.Text = "12" And TextBox2.Text >= "22") Or (TextBox3.Text = "01" And TextBox2.Text <= "20")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Capricornio"

        ElseIf ((TextBox3.Text = "01" And TextBox2.Text >= "21") Or (TextBox3.Text = "02" And TextBox2.Text <= "19")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Acuario"

        ElseIf ((TextBox3.Text = "02" And TextBox2.Text >= "20") Or (TextBox3.Text = "03" And TextBox2.Text <= "20")) Then
            Me.Label1.Visible = "True"
            Label1.Text = ""
            Label1.Text = "signo del zodiaco: Piscis"
        End If
    End Sub

    
End Class

ahora lo importante de este codigo, es que extraemos los primeros 2 valores de nuestro TextBox1 que contiene la fecha que hemos seleccionado en nuestro calendar

TextBox2.Text = Left$(TextBox1.Text, 2)

Bueno se que es una aplicación bastante sencilla y que se puede mejorar mucho como por ejemplo extraer los valores desde una base de datos, pero la dejo disponible para todos

Saludos
Descargar

About these ads

Deja un comentario

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

Categorías

Seguir

Recibe cada nueva publicación en tu buzón de correo electrónico.

%d personas les gusta esto: