Ver Mensaje Individual
  #5 (permalink)  
Antiguo 22/01/2011, 11:02
Avatar de Aquaventus
Aquaventus
 
Fecha de Ingreso: junio-2010
Ubicación: Lima-Peru , En el alba de la naturaleza
Mensajes: 2.105
Antigüedad: 13 años, 10 meses
Puntos: 267
Respuesta: Ayuda con Ordenamiento de numeros por bloques

Hola Totto3 podrias hacer algo como esto :

Código vb:
Ver original
  1. 'Estas variables tienen que ser global
  2. Dim texto As String
  3.     Dim inicial As Int64
  4.     Dim siguiente As Int64
  5.     Dim anterior As Int64

Código vb:
Ver original
  1. 'Este objmn.LISTADOMODULO() es un metodo mio con el que lleno luego a mi datagridview
  2. Dim dtt As DataTable = objmn.LISTADOMODULO()
  3.         Dim num As Int64
  4.  
  5.         For i = 0 To dtt.Rows.Count - 1
  6.             If i = 0 Then
  7.                 inicial = Convert.ToInt64(dtt.Rows(i).Item("NREMISION").ToString)
  8.                 texto = "Del " & inicial.ToString()
  9.             Else
  10.                 If i = dtt.Rows.Count - 1 Then
  11.                     num = Convert.ToInt64(dtt.Rows(i).Item("NREMISION").ToString)
  12.                     anterior = Convert.ToInt64(dtt.Rows(i - 1).Item("NREMISION").ToString)
  13.                     If anterior = (num - 1) Then
  14.                         texto = texto & " al " & inicial.ToString()
  15.                     Else
  16.                         texto = "Del " & inicial.ToString() & " al " & inicial.ToString()
  17.                     End If
  18.                 Else
  19.                     num = Convert.ToInt64(dtt.Rows(i).Item("NREMISION").ToString)
  20.                     siguiente = Convert.ToInt64(dtt.Rows(i + 1).Item("NREMISION").ToString)
  21.                     If (num + 1) <> siguiente Then
  22.                         texto = texto & " al " & inicial.ToString()
  23.                         ListBox1.Items.Add(texto)
  24.                         texto = "Del " & siguiente.ToString()
  25.                     End If
  26.                 End If
  27.                
  28.             End If
  29.         Next
__________________
Internet es tener todo el conocimiento global a tu disposición.
Desarrollo de Software - Ejemplos .Net