elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: (TUTORIAL) Aprende a emular Sentinel Dongle By Yapis


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Ayudas o sugerencias - programa signo zodiaco
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: 1 [2] 3 Ir Abajo Respuesta Imprimir
Autor Tema: Ayudas o sugerencias - programa signo zodiaco  (Leído 31,748 veces)
Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #10 en: 18 Mayo 2009, 01:49 am »

Ahora arreglado el tema de la entrada con mayuscula o minuscula... Usando Ucase() Solo falta depurar un poco más los signos, pero creo que ya esta bien.

Código
  1. Dim dia As String
  2. Dim mes As String
  3. Dim reponse As Boolean
  4. Private Sub Form_Load()
  5.    dia = InputBox("Ingrese dia", "Signos")
  6.    If dia = "" Then
  7.        End
  8.    End If
  9.    While (dia < 1) Or (dia > 31) Or (dia = "")
  10.        MsgBox "Error, los meses solo contienen dias entre 1 y 31", vbOKOnly
  11.        dia = InputBox("Ingrese dia", "Signos")
  12.    Wend
  13.    dia = Val(dia)
  14.    mes = InputBox("Ingrese mes", "Signos")
  15.    mes = UCase(mes)
  16.    Select Case mes
  17.        Case "ENERO"
  18.        If dia < 21 Then
  19.            MsgBox "CAPRICORNIO", vbOKOnly
  20.        Else: MsgBox "ACUARIO", vbOKOnly
  21.        End If
  22.        Case "FEBRERO"
  23.        If dia < 20 Then
  24.            MsgBox "ACUARIO", vbOKOnly
  25.        Else: MsgBox "PISCIS", vbOKOnly
  26.        End If
  27.        Case "MARZO"
  28.        If dia < 21 Then
  29.            MsgBox "PISCIS", vbOKOnly
  30.        Else:  MsgBox "ARIES", vbOKOnly
  31.        End If
  32.        Case "ABRIL"
  33.        If dia < 21 Then
  34.             MsgBox "ARIES", vbOKOnly
  35.        Else: MsgBox "TAURO", vbOKOnly
  36.        End If
  37.        Case "MAYO"
  38.        If dia < 21 Then
  39.            MsgBox "TAURO", vbOKOnly
  40.        Else: MsgBox "GEMINIS", vbOKOnly
  41.        End If
  42.        Case "JUNIO"
  43.        If dia < 21 Then
  44.            MsgBox "GEMINIS", vbOKOnly
  45.        Else: MsgBox "CANCER", vbOKOnly
  46.        End If
  47.        Case "JULIO"
  48.        If dia < 24 Then
  49.           MsgBox "CANCER", vbOKOnly
  50.        Else: MsgBox "LEO", vbOKOnly
  51.        End If
  52.        Case "AGOSTO"
  53.        If dia < 24 Then
  54.            MsgBox "LEO", vbOKOnly
  55.        Else: MsgBox "VIRGO", vbOKOnly
  56.        End If
  57.        Case "SETIEMBRE"
  58.        If dia < 24 Then
  59.            MsgBox "VIRGO", vbOKOnly
  60.        Else: MsgBox "LIBRA", vbOKOnly
  61.        End If
  62.        Case "OCTUBRE"
  63.        If dia < 24 Then
  64.           MsgBox "LIBRA", vbOKOnly
  65.        Else: MsgBox "ESCORPIO", vbOKOnly
  66.        End If
  67.        Case "NOVIEMBRE"
  68.        If dia < 22 Then
  69.            MsgBox "ESCORPIO", vbOKOnly
  70.        Else: MsgBox "SAGITARIO", vbOKOnly
  71.        End If
  72.        Case "DICIEMBRE"
  73.        If dia < 22 Then
  74.            MsgBox "SAGITARIO", vbOKOnly
  75.        Else: MsgBox "CAPRICORNIO", vbOKOnly
  76.        End If
  77.        Case Else
  78.        MsgBox "Error", vbOKOnly
  79. End Select
  80. End
  81. End Sub


En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
Jorgitoh

Desconectado Desconectado

Mensajes: 11


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #11 en: 18 Mayo 2009, 13:26 pm »

Tene en cuenta que estas usando Windows Forms y el user solo esta manejando la Consola. De todos modos la sintaxis esta bien, solo habria que cambiar los Input Box por ReadLine y los Message por WriteLine.

Saludos.


En línea

Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #12 en: 18 Mayo 2009, 16:00 pm »

Si  :xD anoche estuve hablando con el y aclarando un par de dudas que tenia. El problema creo que se ha solucionado.
En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
NetStorm

Desconectado Desconectado

Mensajes: 114


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #13 en: 18 Mayo 2009, 17:54 pm »

Gracias ha sido un trabajo exitoso, lo habeís hecho excelente agradecer profundamente a m@deb su ánimo desinteresado por su ayuda de forma "integra" y no mediocre, paso cerca de 3 horas explicándome muchas cosas que ahora tengo claras aunque en clases ni las he tocado (por ejem. los forms), y nada agradecer a todos los integrantes del foro que también aportaron lo suyo ...

Finalmente quiero solicitarle al mod del foro que de por cerrado el tema, ya que se ha solucionado el problema.

Gracias, sinceramente sos grandes como dice m@deb... vale Che'

Salu2 desde Arequipa - Perú.
En línea

Myth.ck


Desconectado Desconectado

Mensajes: 303


Algorithmics & C++ Studient


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #14 en: 18 Mayo 2009, 18:11 pm »

Pues de nada.
Cuando uno ayuda, tambien aprende muchas cosas, ya que no soy un Gurú de la programación.
Sin mas que decir.

Salu2!
En línea

Un intelectual es un hombre que usa más palabras de las necesarias para decir más cosas de las que sabe.
NetStorm

Desconectado Desconectado

Mensajes: 114


Ver Perfil
SOLUCIÓN !!!
« Respuesta #15 en: 3 Junio 2009, 03:44 am »

Bien para los interesados aquí está el código, como todavía veo que la prgunta está abierta, entonces posteo el código, OJO que esto es en modo consola, M@deb lo realizó en form, pero yo lo adapté a consola. En fin...

Código:
Imports system.console

Module module1
    Sub main()

        Dim dia As Integer
        Dim mes As String
        Dim feberror As Integer = 29

        Const horoaries As String = "hoy tendrás un gran día"
        Const horotauro As String = "hoy tendrás un gran día"
        Const horogeminis As String = "hoy tendrás un gran día"
        Const horocancer As String = "hoy tendrás un gran día"
        Const horoleo As String = "hoy tendrás un gran día"
        Const horovirgo As String = "hoy tendrás un gran día"
        Const horolibra As String = "hoy tendrás un gran día"
        Const horoescorpio As String = "hoy tendrás un gran día"
        Const horosagitario As String = "hoy tendrás un gran día"
        Const horocapricornio As String = "hoy tendrás un gran día"
        Const horoacuario As String = "hoy tendrás un gran día"
        Const horopiscis As String = "hoy tendrás un gran día"

        Writeline("Por favor, ingrese el dia de nacimiento")
        Dia = readline()
        If dia = (dia < 1) Or (dia > 31) Then
            WriteLine("Error, los meses solo contienen dias entre 1 y 31")
            ReadLine()
        Else
            WriteLine("Ahora ingrese el mes de nacimiento")
            mes = ReadLine()
            If mes = ("febrero") And (dia > 29) Then
                WriteLine("Oh, Oh!!!, febrero no tiene " & dia & " días, se le asignará 29 como valor")
                ReadLine()
                dia = 29
            Else
            End If
            mes = UCase(mes)
            Select Case mes
                Case "ENERO"
                    If dia < 21 Then
                        WriteLine("CAPRICORNIO " & horocapricornio)
                        ReadLine()
                    Else : WriteLine("ACUARIO " & horoacuario)
                        ReadLine()
                    End If
                Case "FEBRERO"
                    If dia < 20 Then
                        WriteLine("ACUARIO " & horoacuario)
                        ReadLine()
                    Else : WriteLine("PISCIS " & horopiscis)
                        ReadLine()
                    End If
                Case "MARZO"
                    If dia < 21 Then
                        WriteLine("PISCIS " & horopiscis)
                        ReadLine()
                    Else : WriteLine("ARIES " & horoaries)
                        ReadLine()
                    End If
                Case "ABRIL"
                    If dia < 21 Then
                        WriteLine("ARIES " & horoaries)
                        ReadLine()
                    Else : WriteLine("TAURO " & horotauro)
                        ReadLine()
                    End If
                Case "MAYO"
                    If dia < 21 Then
                        WriteLine("TAURO " & horotauro)
                        ReadLine()
                    Else : WriteLine("GEMINIS " & horogeminis)
                        ReadLine()
                    End If
                Case "JUNIO"
                    If dia < 21 Then
                        WriteLine("GEMINIS " & horogeminis)
                        ReadLine()
                    Else : WriteLine("CANCER " & horocancer)
                        ReadLine()
                    End If
                Case "JULIO"
                    If dia < 24 Then
                        WriteLine("CANCER " & horocancer)
                        ReadLine()
                    Else : WriteLine("LEO " & horoleo)
                        ReadLine()
                    End If
                Case "AGOSTO"
                    If dia < 24 Then
                        WriteLine("LEO " & horoleo)
                        ReadLine()
                    Else : WriteLine("VIRGO " & horovirgo)
                        ReadLine()
                    End If
                Case "SETIEMBRE"
                    If dia < 24 Then
                        WriteLine("VIRGO " & horovirgo)
                        ReadLine()
                    Else : WriteLine("LIBRA " & horolibra)
                        ReadLine()
                    End If
                Case "OCTUBRE"
                    If dia < 24 Then
                        WriteLine("LIBRA " & horolibra)
                        ReadLine()
                    Else : WriteLine("ESCORPIO " & horoescorpio)
                        ReadLine()
                    End If
                Case "NOVIEMBRE"
                    If dia < 22 Then
                        WriteLine("ESCORPIO " & horoescorpio)
                        ReadLine()
                    Else : WriteLine("SAGITARIO " & horosagitario)
                        ReadLine()
                    End If
                Case "DICIEMBRE"
                    If dia < 22 Then
                        WriteLine("SAGITARIO " & horosagitario)
                        ReadLine()
                    Else : WriteLine("CAPRICORNIO " & horocapricornio)
                        ReadLine()
                    End If
                Case Else
                    Write("Oh, oh!!!, ... Ha ocurrido un error los datos ingresados no son válidos")
                    ReadLine()
            End Select
            End If
    End Sub
End Module
En línea

h0oke


Desconectado Desconectado

Mensajes: 2.059


Coder ~


Ver Perfil WWW
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #16 en: 3 Junio 2009, 03:52 am »

Código
  1.        Const horoaries As String = "hoy tendrás un gran día"
  2.        Const horotauro As String = "hoy tendrás un gran día"
  3.        Const horogeminis As String = "hoy tendrás un gran día"
  4.        Const horocancer As String = "hoy tendrás un gran día"
  5.        Const horoleo As String = "hoy tendrás un gran día"
  6.        Const horovirgo As String = "hoy tendrás un gran día"
  7.        Const horolibra As String = "hoy tendrás un gran día"
  8.        Const horoescorpio As String = "hoy tendrás un gran día"
  9.        Const horosagitario As String = "hoy tendrás un gran día"
  10.        Const horocapricornio As String = "hoy tendrás un gran día"
  11.        Const horoacuario As String = "hoy tendrás un gran día"
  12.        Const horopiscis As String = "hoy tendrás un gran día"

Una pregunta.. ¿Por qué declaras tantas veces lo mismo? No daría igual que uses:

Código
  1. Const Horoscopo As String= "Hoy tendrás un gran dia"
En línea

NetStorm

Desconectado Desconectado

Mensajes: 114


Ver Perfil
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #17 en: 6 Junio 2009, 18:26 pm »

Cierto ... tu lógica es aplastante, pero sabes, yo consideré la oportunidad de decirle a cada signo una cosa distinta, y como ves no soy bueno con eso de los horóscopos, imagina que en tu variable coloques "Hoy te amputaran la pierna", ¿a todos los signos les dirás lo mismo?, solo era cuestión de modificar el texto a distintas predicciones para cada signo, eso fue lo que yo consideré, pero como digo ... no soy bueno en eso, será que jamás creo en la suerte.  ;D
En línea

h0oke


Desconectado Desconectado

Mensajes: 2.059


Coder ~


Ver Perfil WWW
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #18 en: 6 Junio 2009, 18:38 pm »

 :D Entonces... no dije nada...  ::) Es verdad lo que dices, pero yo pensé que habias presentado de esa manera el programa.
En línea

seba123neo


Desconectado Desconectado

Mensajes: 3.621



Ver Perfil WWW
Re: Ayudas o sugerencias - programa signo zodiaco
« Respuesta #19 en: 7 Junio 2009, 00:44 am »

Hola, mira este codigo yo lo habia realizado cuando tuve que hacer algo parecido...es una funcion que se encarga de calcular el signo...y te ahorras todos esos SELECT CASE que no me gustan cuando son muchos...

Código
  1. Imports system.console
  2.  
  3. Module module1
  4.    Private Enum MESES
  5.        ENERO = 1
  6.        FEBRERO = 2
  7.        MARZO = 3
  8.        ABRIL = 4
  9.        MAYO = 5
  10.        JUNIO = 6
  11.        JULIO = 7
  12.        AGOSTO = 8
  13.        SEPTIEMBRE = 9
  14.        OCTUBRE = 10
  15.        NOVIEMBRE = 11
  16.        DICIEMBRE = 12
  17.    End Enum
  18.  
  19.    Const horoaries As String = "hoy tendrás un gran día"
  20.    Const horotauro As String = "hoy tendrás un gran día"
  21.    Const horogeminis As String = "hoy tendrás un gran día"
  22.    Const horocancer As String = "hoy tendrás un gran día"
  23.    Const horoleo As String = "hoy tendrás un gran día"
  24.    Const horovirgo As String = "hoy tendrás un gran día"
  25.    Const horolibra As String = "hoy tendrás un gran día"
  26.    Const horoescorpio As String = "hoy tendrás un gran día"
  27.    Const horosagitario As String = "hoy tendrás un gran día"
  28.    Const horocapricornio As String = "hoy tendrás un gran día"
  29.    Const horoacuario As String = "hoy tendrás un gran día"
  30.    Const horopiscis As String = "hoy tendrás un gran día"
  31.  
  32.    Sub main()
  33.  
  34.        Dim dia As Integer
  35.        Dim mes As String
  36.        Dim feberror As Integer = 29
  37.        Dim vMes As MESES
  38.  
  39.        WriteLine("Por favor, ingrese el dia de nacimiento")
  40.        dia = ReadLine()
  41.  
  42.        If dia = (dia < 1) Or (dia > 31) Then
  43.            WriteLine("Error, los meses solo contienen dias entre 1 y 31")
  44.            ReadLine()
  45.        Else
  46.            WriteLine("Ahora ingrese el mes de nacimiento")
  47.            mes = ReadLine()
  48.  
  49.            If mes = ("febrero") And (dia > 29) Then
  50.                WriteLine("Oh, Oh!!!, febrero no tiene " & dia & " días, se le asignará 29 como valor")
  51.                ReadLine()
  52.                dia = 29
  53.            Else
  54.            End If
  55.  
  56.            mes = UCase(mes)
  57.  
  58.            Dim a() As String = System.Enum.GetNames(vMes.GetType)
  59.            Dim vIndiceMes As Integer
  60.            For i As Integer = 0 To a.Length - 1
  61.                If mes = a.GetValue(i) Then
  62.                    vIndiceMes = i + 1
  63.                    WriteLine(Zodiaco(vIndiceMes & dia))
  64.                    ReadLine()
  65.                    Exit Sub
  66.                End If
  67.            Next
  68.  
  69.            WriteLine("Oh, oh!!!, ... Ha ocurrido un error los datos ingresados no son válidos")
  70.            ReadLine()
  71.        End If
  72.    End Sub
  73.  
  74.    Private Function Zodiaco(ByVal Fecha As Integer) As String
  75.        If Fecha <= 219 And Fecha >= 121 Then
  76.            Zodiaco = "ACURARIO " & horoacuario
  77.        ElseIf Fecha <= 320 And Fecha >= 220 Then
  78.            Zodiaco = "PISCIS " & horopiscis
  79.        ElseIf Fecha <= 420 And Fecha >= 321 Then
  80.            Zodiaco = "ARIES " & horoaries
  81.        ElseIf Fecha <= 521 And Fecha >= 421 Then
  82.            Zodiaco = "TAURO " & horotauro
  83.        ElseIf Fecha <= 621 And Fecha >= 522 Then
  84.            Zodiaco = "GEMINIS " & horogeminis
  85.        ElseIf Fecha <= 722 And Fecha >= 622 Then
  86.            Zodiaco = "CANCER " & horocancer
  87.        ElseIf Fecha <= 822 And Fecha >= 723 Then
  88.            Zodiaco = "LEO " & horoleo
  89.        ElseIf Fecha <= 923 And Fecha >= 823 Then
  90.            Zodiaco = "VIRGO " & horovirgo
  91.        ElseIf Fecha <= 1023 And Fecha >= 924 Then
  92.            Zodiaco = "LIBRA " & horolibra
  93.        ElseIf Fecha <= 1122 And Fecha >= 1024 Then
  94.            Zodiaco = "ESCORPIO " & horoescorpio
  95.        ElseIf Fecha <= 1221 And Fecha >= 1123 Then
  96.            Zodiaco = "SAGITARIO " & horosagitario
  97.        Else
  98.            Zodiaco = "CAPRICORNIO " & horocapricornio
  99.        End If
  100.    End Function
  101. End Module

saludos.
« Última modificación: 7 Junio 2009, 00:47 am por seba123neo » En línea

Páginas: 1 [2] 3 Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines