Hola
Desordenar un listbox
Lo veo tan fácil como asignarle un valor aleatorio a cada elemento del listbox y ordenar por allí
Sub Desordenar()
dim Tabla(list1.listcount) as string, TotalEntradas as integer
TotalEntradas=list1.listcount
for x%=0 to TotalEntradas-1 'recorrer el listbox y asignar numero aleatorio
list1.itemdata(x%)=ObtenerNumero(TotalEntradas)
next x%
for x%=0 to TotalEntradas-1 'Ordenar por ese numero y dejar el resultado en tabla
tabla(list1.itemdata(x%))=list1(x%).list
next x%
List1.Clear 'borrar listbox actual
for x%=0 to TotalEntradas-1 'poner las entradas ordenadas por el numero aleatorio
list1.additem tabla(x%)
next x%
end sub
Esta función es la que obtiene el número
function ObtenerNumero(TotalEntradas as Integer)
Dim Numero as integer 'lugar donde quedará el numero obtenido
Dim NumValido as boolean 'para saber si el numero es válido o no
Numero=-1 'empezar con un valor no válido
while not EsValido(Numero,TotalEntradas)
randomize timer
Numero=int(rnd*TotalEntradas))
loop
ObtenerNumero=Numero
End Function
Saber si es válido el número
Function EsValido(Numero as integer,TotalEntradas as integer)
EsValido=true
if Numero<0 then 'si el numero es negativo
EsValido=false
else
for x%=0 to TotalEntradas-1
if list1.itemdata(x%)=Numero then 'si el numero ya había salido antes
EsValido=false
endif
next x%
endif
End Function
buscar un determinado textbox en la lista
Sub Buscar(texto as string)
for x%=0 to list1.listcount-1
if list1(x%).list=texto then
msgbox "Encontrado en la posición: " & x%
endif
next x%
end sub