[Aportes indexados] Borrar un elemento de un array

Estado
Cerrado para nuevas respuestas.

Amraphen

Aprendiz Lvl 6
[ALGORITMO]Borrar un elemento de un array

Buenas, les dejo un código que hize en VB hace no mucho que se usa para borrar un determinado elemento de un array, ya sea numérico o alfanumérico. Espero que les sirva, gente, se los dejo:

[vb]<div class="vb" id="{CB}" style="font-family: monospace;"><ol><li style="" class="li1">&nbsp;</li><li style="" class="li2"><span style="color: #b1b100;">Private</span> <span style="color: #b1b100;">Sub</span> EraseArrayElement<span style="color: #e1e1e1;">(</span><span style="color: #b1b100;">ByRef</span> sArray<span style="color: #e1e1e1;">(</span><span style="color: #e1e1e1;">)</span> <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">String</span>, <span style="color: #b1b100;">ByVal</span> ElementIndex <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span><span style="color: #e1e1e1;">)</span></li><li style="" class="li1"><span style="color: #80C080; font-style: italic;">'Creado por Amraphen</span></li><li style="" class="li2"><span style="color: #b1b100;">Dim</span> i <span style="color: #b1b100;">As</span> <span style="color: #b1b100;">Integer</span></li><li style="" class="li1">&nbsp;</li><li style="" class="li2">&nbsp; &nbsp; <span style="color: #b1b100;">If</span> AppIndex = <span style="color: #b1b100;">UBound</span><span style="color: #e1e1e1;">(</span>sArray<span style="color: #e1e1e1;">)</span> <span style="color: #b1b100;">Then</span></li><li style="" class="li1">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">ReDim</span> Preserve sArray<span style="color: #e1e1e1;">(</span><span style="color: #b1b100;">UBound</span><span style="color: #e1e1e1;">(</span>sArray<span style="color: #e1e1e1;">)</span> - <span style="color: #f1f1f1;">1</span><span style="color: #e1e1e1;">)</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">Exit</span> <span style="color: #b1b100;">Sub</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #b1b100;">End</span> <span style="color: #b1b100;">If</span></li><li style="" class="li2">&nbsp; &nbsp; </li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #b1b100;">For</span> i = AppIndex <span style="color: #b1b100;">To</span> <span style="color: #b1b100;">UBound</span><span style="color: #e1e1e1;">(</span>sArray<span style="color: #e1e1e1;">)</span> - <span style="color: #f1f1f1;">1</span></li><li style="" class="li2">&nbsp; &nbsp; &nbsp; &nbsp; sArray<span style="color: #e1e1e1;">(</span>i<span style="color: #e1e1e1;">)</span> = sArray<span style="color: #e1e1e1;">(</span>i + <span style="color: #f1f1f1;">1</span><span style="color: #e1e1e1;">)</span></li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #b1b100;">Next</span></li><li style="" class="li2">&nbsp; &nbsp; </li><li style="" class="li1">&nbsp; &nbsp; <span style="color: #b1b100;">ReDim</span> Preserve sArray<span style="color: #e1e1e1;">(</span><span style="color: #b1b100;">UBound</span><span style="color: #e1e1e1;">(</span>sArray<span style="color: #e1e1e1;">)</span> - <span style="color: #f1f1f1;">1</span><span style="color: #e1e1e1;">)</span></li><li style="" class="li2"><span style="color: #b1b100;">End</span> <span style="color: #b1b100;">Sub</span></li><li style="" class="li1">&nbsp;</li></ol></div>[/vb]

Saludos!
 
Estado
Cerrado para nuevas respuestas.
Arriba