Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

arrays in vbscript

Status
Not open for further replies.

bhas

Programmer
Mar 17, 2004
30
US
Hi,
Here is my vbscript.
What i want it to do is to go thru the array and look for matching numbers.
The array will have numbers like 25429-8,23456-8 etc..
Please responfd with answers



Function check_val( byref arrArray )
' Dim arrArray()
Dim row, j
Dim StartingKeyValue, NewKeyValue
'CInt(arrArray)
' Dim myArray(3), arraySize
' arraySize = UBound(myArray)
' For Each arrayElement In arrArrary
' For Each arrArray(row)
For row = 0 = UBound(arrArray )
starting value = (arrArray (row))
NewKeyValue = (arrArray (row))
for j = row + 1 = UBound( arrArray)
if arrArrray (row) <> Newkeyvalue Then
NewKeyValue = (arrArray (row))
end if
Next
Next
End function
 
This will find matching numbers but I don't know what you want the function to return
[tt]
Function Check_Val(ByRef arrArray)
Dim row As Integer, j As Integer
For row = LBound(arrArray) To UBound(arrArray) - 1
For j = row + 1 To UBound(arrArray)
If arrArrray(j) = arrArray(row) Then
Debug.Print "Duplicate Value for : " & arrArray(row) & _
" at rows " & row & " and " & j
End If
Next
Next
End Function
[/tt]
 
Golon,
I am using this script in biztalk mapper where based on the match i will map it.
Can i change the script like the following so that i can map it when the values are not matching instead of printing
Thanks

Function Check_Val(ByRef arrArray)
Dim row As Integer, j As Integer
For row = LBound(arrArray) To UBound(arrArray) - 1
For j = row + 1 To UBound(arrArray)
If arrArrray(j) <> arrArray(row) Then
NewKeyValue = (rrArray (row)
Debug.Print "Duplicate Value for : " & arrArray(row) & _
" at rows " & row & " and " & j
End If
Next
Next
End Function
 
I am getting expected end of statement error Dim row as integer
 
Not really sure what you're asking but the issue ... as far as I can see ... is that this is declared as a function which means that it is expected to return a value.

Now ... what value do you want returned?
[li]The subscript of the first match?[/li]
[li]The subscript of the second match?[/li]
[li]The value that matched?[/li]

Assuming that you want the first matching value returned then
[tt]
Function Check_Val(ByRef arrArray)
Dim row As Integer, j As Integer
For row = LBound(arrArray) To UBound(arrArray) - 1
For j = row + 1 To UBound(arrArray)
If arrArrray(j) = arrArray(row) Then
Check_Val = arrArray(row)
Exit Function
End If
Next
Next
Check_Val = ""
End Function
[/tt]

This returns the first value that was duplicated if one was found and it returns an empty string if no duplicates were found.
 
Golon,
I am using this script in biztalk mapper where based on the match i will map it.
Can i change the script like the following so that i can map it when the values are not matching instead of printing
Thanks

Function Check_Val(ByRef arrArray)
Dim row As Integer, j As Integer
For row = LBound(arrArray) To UBound(arrArray) - 1
For j = row + 1 To UBound(arrArray)
If arrArrray(j) <> arrArray(row) Then
NewKeyValue = (rrArray (row)
Debug.Print "Duplicate Value for : " & arrArray(row) & _
" at rows " & row & " and " & j
End If
Next
Next
End Function
 
I want only the values for which there are no matches so that i can use them for the mapping.
 
I am getting expected end of statement error Dim row As Integer, j As Integer
 
Ifixed the dim issue but the lbound and ubound is not working properly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top