Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to remove values from an Array.
#1
Not Solved
guys, I know this question may be straight forward. but I am a beginner and nees to know how to remove specific values from an array. I have a Dynamic Array in_Str_SecurityQ2 like below

Code:
in_Str_SecurityQ2_List = Browser("br_EMC").Page("pg_ViewProfile").WebElement("ele_SecurityQ2_List").GetROProperty("innertext")
in_Str_SecurityQ2 = Split(in_Str_SecurityQ2_List,"?")

this array has UBpund as 16 and contains values as below.

What is the first name of your oldest nephew?
What is the first name of the best man at your wedding?
(Enter full name of street only)?
What was the first name of your first boyfriend/girlfriend?
What was the first name of your first manager?
(Enter full name of town only)?
What is the first name of your oldest niece?
(Enter full name of city only)What is the name of the first company you worked for?
What is your grandfather's nickname?
............

I want to remove the values (Enter full name of street only)? and (Enter full name of town only)? from the Array and also update the size accordingly.

Thanks in Advance.
Reply
#2
Not Solved
You can use REPLACE Built-In Function of Vbscript. Below is the script.

A(0) = "What is the first name of your oldest nephew?"
B(0) = Replace(A(0),"?","")
Msgbox B(0)
Reply
#3
Not Solved
I am not sure if what you told will help me as I need to remove "(Enter full name of street only)?" and "(Enter full name of town only)?" these two values from the Array, also the index is not fixed for them.
Reply
#4
Not Solved
Instead of using array you can give Scripting.Dictionary a try.

It is much more flexible, and has, among others Remove method.
Reply
#5
Not Solved
thanks I will try it Smile
Reply
#6
Not Solved
Try this...

Code:
Qtn = ("a;b;c;d")
Arr = Split(Qtn,";")
ItemToBeDeleted = "b"
Brr = ToDeleteEle( Arr , ItemToBeDeleted)


Function ToDeleteEle (Arr , ItemToBeDeleted)
   For i = 0 to UBound(Arr)
       If Arr(i) =  ItemToBeDeleted Then
           While i<UBound(Arr)
               Arr(i) = Arr(i+1)
               i=i+1
           Wend
       End If

   Next
   ReDim Preserve Arr(Ubound(Arr)-1)
  ToDeleteEle = Arr
End Function
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to remove the spaces from a string Anand 7 28,491 08-12-2019, 04:47 PM
Last Post: sreekanthP
  How to remove text in the webedit silpavinod 3 13,388 07-12-2018, 11:08 AM
Last Post: vijaychourasiya0109@gmail.com
  how to remove null values in array venkatesh9032 0 2,763 02-19-2014, 06:51 PM
Last Post: venkatesh9032
  How to convert a single dimension array to two dimensional array venkatesh9032 3 5,222 02-10-2014, 03:07 PM
Last Post: pranikgarg
  Adding array to another Global array in VB Script test911 1 3,010 12-02-2012, 12:40 PM
Last Post: parminderdhiman84

Forum Jump:


Users browsing this thread: 1 Guest(s)