
14/06/2013, 11:48
|
| | Fecha de Ingreso: noviembre-2010
Mensajes: 175
Antigüedad: 14 años, 3 meses Puntos: 1 | |
Respuesta: Ordenar fechas en un vector (bubble sort) Cita:
Iniciado por erbuson Hola:
Prueba a ver si funciona como quieres, de no ser así creo que con pocas modificaciones valdra.
Código vb:
Ver originalOption Explicit Public Sub SortBurbuja(Datos() As Date) ' Ordena por Burbuja la matriz recibida Orden Ascendente Dim Elemento As Integer, Bucle As Integer, Temporal As Date For Elemento = 0 To UBound(Datos) For Bucle = Elemento + 1 To UBound(Datos) If Datos(Bucle) < Datos(Elemento) Then Temporal = Datos(Bucle) Datos(Bucle) = Datos(Elemento) Datos(Elemento) = Temporal End If Next Next End Sub Private Sub Form_Load() Dim Datos(9) As Date Datos(0) = "31/12/2012" Datos(1) = "30/12/2012" Datos(2) = "29/12/2012" Datos(3) = "28/12/2012" Datos(4) = "27/12/2012" Datos(5) = "26/12/2012" Datos(6) = "25/12/2012" Datos(7) = "24/12/2012" Datos(8) = "23/12/2012" Datos(9) = "22/12/2012" SortBurbuja Datos Dim Indice As Integer For Indice = 0 To 9 Form1.Print Datos(Indice) Next End Sub
Saludos
gracias! |