|
-
Mar 18th, 2001, 09:12 AM
#1
Thread Starter
Member
I have an array. some of the elements in this array is empty. How can I kick away all those that is empty and the whole array can move upward? (i.e. pack all those are empty)
Please Visit My WebCam!!
http://www.hmcheung.com
-
Mar 18th, 2001, 09:33 AM
#2
Addicted Member
Possible
That's possible, I'm a bit busy right now, but I'll make a sample code for you as soon as I can, and when the solution isn't already given.
Quintonir
-
Mar 18th, 2001, 10:14 AM
#3
-
Mar 18th, 2001, 10:56 AM
#4
PowerPoster
Try this:
Code:
Dim sArray() As String
Dim A As Long
Dim Count As Long
ReDim sArray(9)
sArray(0) = "Hello"
sArray(1) = "My"
sArray(2) = ""
sArray(3) = "Name"
sArray(4) = "Is"
sArray(5) = "Quintonir"
sArray(6) = ""
sArray(7) = "What"
sArray(8) = "Is"
sArray(9) = "Yours?"
Count = 0
For A = 0 To UBound(sArray, 1)
If Not sArray(A) = "" Then
sArray(Count) = sArray(A)
Count = Count + 1
End If
Next
Count = Count - 1
If Count < 0 Then
Erase sArray
Else
ReDim Preserve sArray(Count)
End If
'Code improved by vBulletin Tool (Save as...)
-
Mar 18th, 2001, 10:59 AM
#5
Addicted Member
VB Code
Hiya Fox, could you please share the knowledge on how to add the code in Visual Basic format ??
-
Mar 18th, 2001, 11:01 AM
#6
PowerPoster
See the last line in my code I use my vB Tool to coloize the code..
But you may also use the [code] 'Code here [/code] -tags to get formatted code without colors..
-
Mar 18th, 2001, 11:10 AM
#7
Addicted Member
Thanks
Thank you very much, that will improve people's understanding of my posted codes!
-
Mar 18th, 2001, 11:13 AM
#8
PowerPoster
True true... unformatted code is worse than anything else
-
Mar 18th, 2001, 11:17 AM
#9
Addicted Member
Re-port code
Ok, now that I have found out the new way of posting code:
Code:
Dim sArray(): ReDim sArray(1 To 10)
Dim Count, Count2 As Long
sArray(1) = "Hello"
sArray(2) = ""
sArray(3) = "My"
sArray(4) = "Name"
sArray(5) = "Is"
sArray(6) = "Quintonir"
sArray(7) = ""
sArray(8) = "What"
sArray(9) = "Is"
sArray(10) = "Yours?"
For Count = UBound(sArray) To LBound(sArray) Step -1
If sArray(Count) = "" Then
For Count2 = Count To UBound(sArray) - 1
sArray(Count2) = sArray(Count2 + 1)
Next
sArray(UBound(sArray)) = ""
ReDim Preserve sArray(1 To (UBound(sArray) - 1))
End If
Next
' Array fixed!
-
Mar 18th, 2001, 11:56 AM
#10
PowerPoster
Wasn't my solution better?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|