Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Delete An Array Element

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,44
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Delete An Array Element
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Delete An Array Element - 5/23/2001 9:28:02 PM   
  subnation

 

Posts: 20
Score: 0
Joined: 5/22/2001
From: USA
Status: offline
Hi,

Does anyone out there know a way to delete an array element from an array?

Background: I split a string into an array so I could get a portion of it into a variable. I don't need that portion of the array anymore so I blanked it out. However, now I just want to get rid of the blank entry in my array. Following is the code:


dim strRequest 'desired string
dim strFound 'boolean
dim numberChar 'variable holder
dim theParts 'Array
dim theString

theString = "10.11.130.80 - - [01/May/2001:13:52:59 -0600] 'GET /insuredacct/index.cfm HTTP/1.0' 200 355 "

'split string into Array Parts, array automatically creates
theParts = split(theString,"'")
strFound = False
For i = LBound(theParts) to UBound(theParts)
numberChar = left(theParts(i), 4)
response.write "<br>" & numberChar
If strcomp(numberchar, "GET ")=0 then
'assign that part to the strRequest variable
strRequest = theParts(i)
strFound = True
'now that we located strRequest, replace its section in array with blanks
theParts(i) = " "
response.write "<br>" & "String was replaced with blanks."
exit for 'after finding string, exit loop
End If
Next

'**********************
'REVIEW PARTS POST-SEARCH
'**********************
response.write "<hr></hr>"
response.write "<B>Part Review (After Search)</B> <br>"
For i = LBound(theParts) to UBound(theParts)
response.write theParts(i) & "<br>"
Next
response.write "<hr></hr>"



If I print out my Array, here's what I have:


Part Review (After Search)
10.11.130.80 - - [01/May/2001:13:52:59 -0600]

200 355



All I want now is:


Part Review (After Search)
10.11.130.80 - - [01/May/2001:13:52:59 -0600]
200 355


Because I'll have to split these up too based on spaces.

Your help is greatly appreciated.

Thanks in advance,
 
 
Post #: 1
 
 Re: Delete An Array Element - 5/23/2001 9:29:24 PM   
  israelda

 

Posts: 13
Score: 0
Joined: 5/23/2001
From: Israel
Status: offline
The only way to "delete" an element is to copy the array except for that element. How about "marking" it with data that the user could not enter

theParts(i) = Chr(8) ' Clear entry to BACKSPACE
..........
For i = LBound(theParts) to UBound(theParts)
if theParts(I) <> Chr(8) then
response.write theParts(i) & "<br>"
End If
Next

(in reply to subnation)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Delete An Array Element Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts