Nuevas NORMAS para el foro

Curso Hacker
Bienvenido(a), Visitante. Favor de ingresar o registrarse.
¿Perdiste tu email de activación? - Agosto 29, 2008, 06:36:40
Boton Buscar
Inicio Ayuda Ingresar Registrarse
Visita: Articulos - Juegos Gratis - Da Foros

Comunidad Underground Hispana  |  Programacion  |  Programación  |  Visual Basic y Net (Moderador: ANYD00M)  |  Tema: Donde esta el fallo en este generador? 0 Usuarios y 1 Visitante están viendo este tema. « anterior próximo »
Páginas: [1] Ir Abajo Imprimir
Autor Tema: Donde esta el fallo en este generador?  (Leído 245 veces)
Saok
Gran Colaborador
*****
Desconectado Desconectado

Mensajes: 2824


Saok siempre esta ahi...


Ver Perfil WWW
« en: Noviembre 12, 2006, 07:53:28 »

Citar
Private Sub Command1_Click()
Dim appelle As String
Dim Num As Byte
Num = Int((Rnd * 9) + 1)
If Num = 1 Then
appelle = "nombre_el"
Else
If Num = 2 Then
appelle = "nombre_tu"
Else
If Num = 3 Then
appelle = "nombre_yo"
Else
If Num = 4 Then
appelle = "nombre_antonio"
Else
If Num = 5 Then
appelle = "nombre_diego"
Else
If Num = 6 Then
appelle = "nombre_jorge"
Else
If Num = 7 Then
appelle = "nombre_carlos"
Else
If Num = 8 Then
appelle = "nombre_pepe"
Else
If Num = 9 Then
appelle = "nombre_juan"
Label1.Caption = appelle
End If
    End If
        End If
            End If
                End If
                    End If
                        End If
                            End If
                                End If
End Sub

Bien todo eso va dentro de un boton,y ay una Label1,entonces lo que yo prentendia esque se generara un numero aleatorio (que lo hace) y ese numero lo fuera comparando y usara el nombre que tubiera dicho numero.

lo que pasa esque no me da ningun error de sinstaxis ni nada,simplemente algo falla y no se que es,le doy a boton pero no genera el nombre.

Lo que intento es hacer un generador de nombres aleatorios.

saludos[sh]
En línea


Para ver los enlaces debes ser usuario Crear Usuario o Hacer Sesion
www.colgados.net
  date una pasadita por esta web de warez !
sNipeR-
Visitante
« Respuesta #1 en: Noviembre 12, 2006, 08:24:40 »

Wenas

Código:
Private Sub Command1_Click()
Dim num As Integer
Dim name As String
   num = Int((Rnd * 9) + 1)
   If num = 1 Then
      name = "nombre_el"
   ElseIf num = 2 Then
      name = "nombre_tu"
   ElseIf num = 3 Then
      name = "nombre_yo"
   ElseIf num = 4 Then
      name = "nombre_antonio"
   ElseIf num = 5 Then
      name = "nombre_diego"
   ElseIf num = 6 Then
      name = "nombre_jorge"
   ElseIf num = 7 Then
      name = "nombre_carlos"
   ElseIf num = 8 Then
      name = "nombre_pepe"
   ElseIf num = 9 Then
      name = "nombre_juan"
   End If
   Label1.Caption = name
End Sub

Salu2
« Última modificación: Noviembre 12, 2006, 08:27:27 por $N!PER » En línea
Hendrix
Visitante
« Respuesta #2 en: Noviembre 12, 2006, 09:14:38 »

Tambien se puede hacer con case

Código:
Private Sub Command1_Click()
Dim appelle As String
Dim Num As Byte
Num = Int((Rnd * 9) + 1)
Select Case Num
    Case 1
        appelle = "nombre_el"
    Case 2
        appelle = "nombre_tu"
    Case 3
        appelle = "nombre_yo"
    Case 4
        appelle = "nombre_antonio"
    Case 5
        appelle = "nombre_diego"
    Case 6
        appelle = "nombre_jorge"
    Case 7
        appelle = "nombre_carlos"
    Case 8
        appelle = "nombre_pepe"
    Case 9
        appelle = "nombre_juan"
End Select

MsgBox appelle
End Sub

Salu2

En línea
sNipeR-
Visitante
« Respuesta #3 en: Noviembre 12, 2006, 09:18:54 »

Exacto, yo he puesto con ElseIf para k Saok vea k se puede tornar mucho mas simple el metodo k estava usando con todos akeles end if's xD

Salu2
En línea
Saok
Gran Colaborador
*****
Desconectado Desconectado

Mensajes: 2824


Saok siempre esta ahi...


Ver Perfil WWW
« Respuesta #4 en: Noviembre 12, 2006, 10:16:20 »

ola

jajajaj si gracias tomo nota.  Otra duda:

Veamos,ese codigo lo tengo dentro de un sub y y es llamado desde el form load,entonces necesito que ese codigo se ejecute 3 veces y luego siga....alguna idea.....estu mirando un poco con if pero me andaba error.


saludos[sh]
En línea


Para ver los enlaces debes ser usuario Crear Usuario o Hacer Sesion
www.colgados.net
  date una pasadita por esta web de warez !
Hendrix
Visitante
« Respuesta #5 en: Noviembre 12, 2006, 10:33:48 »

Código:
public function nombre()
Dim appelle As String
Dim Num As Byte
Num = Int((Rnd * 9) + 1)
Select Case Num
    Case 1
        appelle = "nombre_el"
    Case 2
        appelle = "nombre_tu"
    Case 3
        appelle = "nombre_yo"
    Case 4
        appelle = "nombre_antonio"
    Case 5
        appelle = "nombre_diego"
    Case 6
        appelle = "nombre_jorge"
    Case 7
        appelle = "nombre_carlos"
    Case 8
        appelle = "nombre_pepe"
    Case 9
        appelle = "nombre_juan"
End Select

MsgBox appelle
end function

Luego podrias hacer esto:

Código:
nombre
nombre
nombre

O

Código:
for i=1 to 3
nombre
next

Salu2

En línea
Saok
Gran Colaborador
*****
Desconectado Desconectado

Mensajes: 2824


Saok siempre esta ahi...


Ver Perfil WWW
« Respuesta #6 en: Noviembre 12, 2006, 10:49:53 »

Citar
Private sub form_load()
for i=1 to 3
nombre
next
codigo
codigo
codigo
end sub

Citar
Public Function nombres()
Dim num As Integer
Dim name As String
   num = Int((Rnd * 9) + 1)
   If num = 1 Then
      name = "nombre_el"
   ElseIf num = 2 Then
      name = "nombre_tu"
   ElseIf num = 3 Then
      name = "nombre_yo"
   ElseIf num = 4 Then
      name = "nombre_antonio"
   ElseIf num = 5 Then
      name = "nombre_diego"
   ElseIf num = 6 Then
      name = "nombre_jorge"
   ElseIf num = 7 Then
      name = "nombre_carlos"
   ElseIf num = 8 Then
      name = "nombre_pepe"
   ElseIf num = 9 Then
      name = "nombre_juan"
   End If
   programa (name)
End function

Citar
Function programa (name as string)
label1.caption = name
codigo
codigo
codigo
end function


Asi iria bien o no se puede llamar desde una Public Funtion a otra Function.

saludos[

En línea


Para ver los enlaces debes ser usuario Crear Usuario o Hacer Sesion
www.colgados.net
  date una pasadita por esta web de warez !
Hendrix
Visitante
« Respuesta #7 en: Noviembre 12, 2006, 11:56:28 »

Claro ek se puede llamar.... Wink Wink

Salu2

En línea
Páginas: [1] Ir Arriba Imprimir 
Comunidad Underground Hispana  |  Programacion  |  Programación  |  Visual Basic y Net (Moderador: ANYD00M)  |  Tema: Donde esta el fallo en este generador? « anterior próximo »
Ir a:  


Ranking-Hits
Powered by SMF 1.1.5 | SMF © 2006-2007, Simple Machines LLC