• Viernes 29 de Marzo de 2024, 11:36

Autor Tema:  Me Podrian Ayudar  (Leído 1758 veces)

JDAFT

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Me Podrian Ayudar
« en: Miércoles 7 de Septiembre de 2005, 00:27 »
0
:huh: unm.. bueno me dejaron un ejercicio de vb donde tengo que escribir 3 numeros cualquiera y se orden de mayor a menor... en lo que yo hice se ordenan 3 numeros pero solo 3 numeros seguidos'... mejor dicho captura el mayor y el menor'.. pero el medio no.. :angry:  .. les copio el codigo.. :whistling:


Dim a, b, c As Integer
Private Sub CmdLimpiar_Click()
txtN1 = ""
txtN2 = ""
txtN3 = ""
txtN1.SetFocus
End Sub

Private Sub cmdOrdenar_Click()
a = Val(txtN1)
b = Val(txtN2)
c = Val(txtN3)
If a > b Then
    If a > c Then
        mayor = a
    Else
        mayor = c
    End If
Else
    If b > c Then
        mayor = b
    Else
        mayor = c
    End If
End If
txtN1 = Str(mayor)



If a < b Then
    If a < c Then
        menor = a
    Else
        menor = c
    End If
Else
    If b < c Then
        menor = b
    Else
        menor = c
    End If
End If
txtN3 = Str(menor)


End Sub

Private Sub cmdSalir_Click()
End
End Sub




muchas gracias..  :comp: para cualquier cosa mi msn es j_daft@hotmail.com para mayor parte del tiempo en internet'.. recien estoy entrando en Vb.. por eso es que estoy algo volado en este tema.. :smartass: sere un buen alumno'

Roll

  • Miembro activo
  • **
  • Mensajes: 76
    • Ver Perfil
Re: Me Podrian Ayudar
« Respuesta #1 en: Sábado 10 de Septiembre de 2005, 17:35 »
0
mira este codigo
no lo he probado pero creo q esta bien

Código: Text
  1. If (a &#62; b And b &#62; c) Then
  2.     mayor = a
  3. Else
  4.     If (a &#62; b And b &#60; c) Then
  5.         If a &#62; c Then
  6.             mayor = a
  7.         Else
  8.             mayor = c
  9.         End If
  10.     Else
  11.         If (a &#60; b And b &#60; c) Then
  12.             mayor = c
  13.         Else
  14.             mayor = b
  15.         End If
  16.     End If
  17. End If
  18.  
  19.  

ojala te sirva

Saludos
WOOOOOOOOOOOOOOOOOOOOOOOOOP