As of now, I'm sending only an empty array through the query-string.
selectPONumber=[]
Have no idea why I'm getting this error. The stacktrace points the Next on this.
If context.Request.QueryString("selectPONumber").Count <> 0 Then
For u = 1 To request.QueryString("selectPONumber").Count
selectPONumber.Add(request.QueryString("selectPONumber")(u))
Next
End If
How is it getting past the if if the .Count is 0? Is my query string formatting incorrect?
If it had values it would look like
selectPONumber=[value1, value2,...]
Many thanks in advance!
Extra Credit
Yes, vb.net did not read selectPONumber as an array when using []. All that's necessary is to to do selectPONumber=value1, value2,...
Thank-you very much for the above and beyond!
Are you saying your querystring looks like this?
mysite/mypage.aspx?selectPONumber=[]
If so, you are passing the string "[]" and Context.Request.QueryString("selectPONumber").Count == 2. It would evaluate to 0 for mysite/mypage.aspx?selectPONumber=.
Also, VB.NET arrays are zero-based. Use:
For u = 0 To request.QueryString("selectPONumber").Count-1
Related
As part of my nightwatchjs testing script, I have a 'dynamic' array that I would like to add a character to.
So, at the moment my array has a value of 4000, but I would like this to read 4,000.
This means that I need to add a , to my array.
The issue I have however, is that this value could change the next time I run the test script, so it could be 10000 or 100000.
So I suppose what I'm asking is whether it's possible to "select a value 3 elements from the end of my array?"
So no matter what or how many elements are in the array, the array will read xx,000.
Any help would be much appreciated. Many thanks.
Does this array have a single value? If so, why is it an array instead of just a variable?
You can use toLocaleString() to add commas to a numeric value, but it will return a string and not a number.
let arr = [4000]
let num = arr[0]
let commas = num.toLocaleString()
console.log(commas)
// "4,000"
For example, I have a string A-456-BC-123;DEF-456;GHI-789. And I need to search for second part:DEF-456 with keyword 456. The potential problem here is that the first part A-456-BC-123 also has the keyword 456. Currently my logic is that, split the string first using ;, split each of it again using -, get the last item of this Array, search keyword 456. Another thing is that I don't want to do a full keyword match like DEF-456, I only want to use 456 as keyword to locate DEF-456, in other words, 456 should be the last segment of the string I want.
Here are my codes:
FirstSplit= split("A-456-BC-123;DEF-456;GHI-789",";")
For each code in FirstSplit
SecondSplit = split(FirstSplit,"-")
'get Array Count
Count = Ubound(SecondSplit)
'get the last item in Array
If SecondSplit(Count-1) = "456" Then
'doing something
End if
Next
Currently, an error will generate at SecondSplit(Count-1), saying that "Subscript out of range: '[number: -1]'"
Could someone tell me how to fix it?
The real problem is here:
SecondSplit = Split(FirstSplit, "-")
You should be splitting your element which you've stored in variable code from your For Each loop. By trying to split an array you should be getting a Type Mismatch error, but perhaps vbscript is forgiving enough to attempt and return a 0 element array back or something. Anyway:
SecondSplit = Split(Code, "-")
Also, to look at the last element just use:
If secondSplit(Ubound(SecondSplit)) = "456" Then
Subtracting 1 from the ubound would get you the second to last element.
You don't need to split it twice - what you're looking for is Right():
FirstSplit = split("A-456-BC-123;DEF-456;GHI-789",";")
For each code in FirstSplit
If Right(code, 3) = "456" Then
' do something
End If
Next
Though this would also match an entry like ABC-1456. If the - symbol is a required delimiter, you'd have to say If Right(code, 4) = "-456".
I'm having some troubles doing something easy: checking the most recent date in an array. I create an array of webelements. There are some dates in this array in "fixed" places and I want to take the most recent of them.
This is what I'm doing:
Set cc = Description.Create
cc("micclass").value="WebElement"
cc("name").value="arrow_down"
Set collcc=Browser("Br").Page("Page").ChildObjects(cc)
For i=lbound(collcc) to ubound(collcc)
Msgbox collcc(x).getroproperty("innertext")
x =x +9
Next
The problem is that the script stops at the beginning of the for, saying that there is a "wrong number of arguments or invalid property assignment ubound" (and the same happens with lbound.
What am I doing wrong?!
Just from memory, but i think ChildObjects does not return an array. Try with
for i = 0 to collcc.Count - 1
....
next
Child object is the collection of objects so you needs to loop through "for each " Snippet given below
for each col in collcc
Msgbox col.getroproperty("innertext")
Next
Thanks
Sai
I have this test code in VB:
Dim st As New ScheduledTasks("\\webserver")
Dim tasknames() As String = st.GetTaskNames
ListBox1.Items.Add(tasknames(1))
st.Dispose()
When i run it i get an error on line:
ListBox1.Items.Add(tasknames(1))
Index was outside the bounds of the array.
Does anyone have any suggestions what im doing wrong?
tasknames must contain at least 2 items for your code to work. (Note that arrays are 0-based, so you start counting at 0)
You have to check whether it really contains that amount:
If tasknames.Length >= 2
Then
ListBox1.Items.Add(tasknames(1))
End If
So, I have an array
//loop here
nummobs = nummobs + 1
Mobs = {}
Mobs[nummobs] = Entity.Init(x(locations to spawn mob), y(locations to spawn mob),"testMob")
Then, call the draw method...
for i = 0, table.getn(Mobs) do
Mobs[i].draw()
end
Error: map.lua:54(Mobs[i].draw() line): attempt to index field '?' (a nil value)... BUT IT HAS SOMETHING IN IT! right?
Anyone ever try something like this? Can anyone fix it?
Thanks
Nate
Lua uses 1-based indexes for arrays. Thus, the range of an array is [1, n] inclusive, where n is the number of elements.
More importantly, you can use ipairs and not have to write out the loop components:
for i, mob in ipairs(Mobs) do
mob:draw()
end
Oh, and never use getn; use the # length operator instead.