Autor
|
Tema: Ayuda ordenar un list de manera ascendente o descendente (Leído 11,448 veces)
|
themindmaster
Desconectado
Mensajes: 32
|
T_____T otro programa, en el cual tengo que pedir ayuda perdonen las molestias enserio T_T el codigo no me funciona me da error al principio
|
|
|
En línea
|
El sabio no se sienta para lamentarse, sino que se pone alegremente a su tarea de reparar el daño hecho.
|
|
|
Danyfirex
Desconectado
Mensajes: 493
My Dear Mizuho
|
El insertionSort esta hecho en vb.net.
pero que has hecho que no te funciona?
|
|
|
En línea
|
|
|
|
themindmaster
Desconectado
Mensajes: 32
|
entonces el codigo de arriba no funciona?
|
|
|
En línea
|
El sabio no se sienta para lamentarse, sino que se pone alegremente a su tarea de reparar el daño hecho.
|
|
|
themindmaster
Desconectado
Mensajes: 32
|
Solo quiero que me ordene los numeros añadidos al listbox si le doy al optionbotom ascendente me los ordenara de manera ascendente pero si le doy a descendente me los ordenara de manera descendente
|
|
|
En línea
|
El sabio no se sienta para lamentarse, sino que se pone alegremente a su tarea de reparar el daño hecho.
|
|
|
Danyfirex
Desconectado
Mensajes: 493
My Dear Mizuho
|
A ver. Te la pongo facil. usa este algoritmo 'true ascendente, false descendente Public Sub BubbleSort(ByRef iaArray() As Long, Optional ByVal tipo As Boolean = True) Dim n As Integer, i As Integer, j As Integer n = UBound(iaArray) For i = (n - 1) To 0 Step -1 For j = 0 To i If tipo = True Then If iaArray(j) > iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If Else If iaArray(j) < iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If End If Next j Next i End Sub
que tienes que hacer. lo siguiente. coger todos los elementos del listbox en un array. luego limpiar el listbox luego llamar la rutina Call BubbleSort(arreglo(), True) luego llenar el listbox otra vez. saludos
|
|
|
En línea
|
|
|
|
themindmaster
Desconectado
Mensajes: 32
|
me da error dice que se esperaba endsub T___T saludos!
|
|
|
En línea
|
El sabio no se sienta para lamentarse, sino que se pone alegremente a su tarea de reparar el daño hecho.
|
|
|
Danyfirex
Desconectado
Mensajes: 493
My Dear Mizuho
|
Muestra tu código completo
|
|
|
En línea
|
|
|
|
themindmaster
Desconectado
Mensajes: 32
|
jajajaja perdona se me olvido recargar la pagina mira el codigo Private Sub cmdañadir_Click() lstnumero.AddItem (txtnumero) End Sub Private Sub cmdordenar_Click() Public Sub BubbleSort(ByRef iaArray() As Long, Optional ByVal tipo As Boolean = True) Dim n As Integer, i As Integer, j As Integer n = UBound(iaArray) For i = (n - 1) To 0 Step -1 For j = 0 To i If tipo = True Then If iaArray(j) > iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If Else If iaArray(j) < iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If End If Next j Next i End Sub
|
|
|
En línea
|
El sabio no se sienta para lamentarse, sino que se pone alegremente a su tarea de reparar el daño hecho.
|
|
|
Danyfirex
Desconectado
Mensajes: 493
My Dear Mizuho
|
Estas declarando un rutina dentro de otra :S debería ser algo así. Private Sub Ordenar_Click() Dim i As Long Dim arreglo() As Long ReDim arreglo(List1.ListCount - 1) For i = 0 To List1.ListCount - 1 arreglo(i) = Int(List1.List(i)) Next For i = 0 To UBound(arreglo) Next Call BubbleSort(arreglo(), True) List1.Clear For i = 0 To UBound(arreglo) List1.AddItem arreglo(i) Next End Sub 'true ascendente, false descendente Public Sub BubbleSort(ByRef iaArray() As Long, Optional ByVal tipo As Boolean = True) Dim n As Integer, i As Integer, j As Integer n = UBound(iaArray) For i = (n - 1) To 0 Step -1 For j = 0 To i If tipo = True Then If iaArray(j) > iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If Else If iaArray(j) < iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If End If Next j Next i End Sub Private Sub Swap(ByRef xArg1, ByRef xArg2) Dim xTmp xTmp = xArg2 xArg2 = xArg1 xArg1 = xTmp End Sub
PD: te recomiendo que leas mas sobre vb6( al menos lo básico ¬¬) lo estas haciendo al azar. saludos
|
|
|
En línea
|
|
|
|
themindmaster
Desconectado
Mensajes: 32
|
este es el codigo que puse y me da un errorsillo: Private Sub cmdañadir_Click() lstnumero.AddItem (txtnumero) End Sub Private Sub cmdordenar_Click() Dim i As Long Dim arreglo() As Long ReDim arreglo(List1.ListCount - 1) For i = 0 To List1.ListCount - 1 arreglo(i) = Int(List1.List(i)) Next For i = 0 To UBound(arreglo) Next Call BubbleSort(arreglo(), True) List1.Clear For i = 0 To UBound(arreglo) List1.AddItem arreglo(i) Next End Sub 'true ascendente, false descendente Public Sub BubbleSort(ByRef iaArray() As Long, Optional ByVal tipo As Boolean = True) Dim n As Integer, i As Integer, j As Integer n = UBound(iaArray) For i = (n - 1) To 0 Step -1 For j = 0 To i If tipo = True Then If iaArray(j) > iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If Else If iaArray(j) < iaArray(j + 1) Then Swap iaArray(j), iaArray(j + 1) End If End If Next j Next i End Sub Private Sub Swap(ByRef xArg1, ByRef xArg2) Dim xTmp xTmp = xArg2 xArg2 = xArg1 xArg1 = xTmp End Sub
error 424 se requiere un objeto
|
|
|
En línea
|
El sabio no se sienta para lamentarse, sino que se pone alegremente a su tarea de reparar el daño hecho.
|
|
|
|
Mensajes similares |
|
Asunto |
Iniciado por |
Respuestas |
Vistas |
Último mensaje |
|
|
ordenar base de datos de manera ascendente
PHP
|
adamsst
|
7
|
2,732
|
15 Mayo 2015, 22:40 pm
por engel lex
|
|
|
Ayuda please! Ordenar numero de forma ascendente
Programación C/C++
|
bryanrz96
|
1
|
1,980
|
13 Noviembre 2015, 22:19 pm
por 0xFer
|
|
|
bubble sort ascendente y descendente en un solo codigo
Programación C/C++
|
Paul Young
|
7
|
4,752
|
7 Marzo 2016, 16:15 pm
por engel lex
|
|
|
ordenar por apellido ascendente, y por nombre descendente
Programación C/C++
|
matiapache12
|
1
|
2,750
|
26 Octubre 2016, 18:08 pm
por palacio29
|
|
|
Ascendente, Descendente y fecha del sistema en ANSI C
Programación C/C++
|
paulin.c
|
1
|
1,879
|
4 Diciembre 2017, 16:57 pm
por do-while
|
|