Hey,
I read a textfile with to variables.
Example :
\\BHBRVFSE004\H$\RETAILDATA\RMKT\RMKRPB\DATA\RMKIS;FONSEIL
\\BHBRVFSE010\J$\DATA\REGIO\ARTAGE34\HOME\ORREC\PROFILE;BRREC
\\BHBRVFSE010\J$\DATA\REGIO\ARTAGE34\HOME\ORREC;BRREC
\\BHBRVFSE010\J$\DATA\REGIO\ARTAGE34\HOME\ROUXD\PROFILE;DOUXD
\\BHBRVFSE010\J$\DATA\REGIO\ARTAGE34\HOME\ROUXD;DOUXD
\\BHBRVFSE010\J$\DATA\REGIO\ARTAGE34\HOME\SASSM\PROFILE;LASSM
\\BHBRVFSE010\J$\DATA\REGIO\ARTAGE34\HOME\SASSM;LASSM
\\BHBRVFSE010\J$\DATA\REGIO\ARTAGE65A\HOME\MEWIR;MEWIR
I can seperate this 2 varables and I want the last varable(suserid) putting in a array to remove the doubles and counting only the singles but he give me always this error :
Type mismatch : array or user-defined type expected.
this error occurs when a want to call my Function routine.
Probably because my function needs a variant array and my intitialarray is a string array.
How can I rsolve this problem?
Sub ReadInputFile8()
look for my code
-------------------
Only the read code to seperate the 2 fields are not given because it works correctly.
Dim initialArray() as string
If ctrLines = 1 Then
Temp_Array = CStr(sUserid)
'Temp_Array = sUserid
Else
'Temp_Array = Temp_Array & Chr$(34) & "," & Chr$(34) & CStr(sUserid)
Temp_Array = Temp_Array & vbLf & sUserid
End If
Wend
initialArray() = Split(Temp_Array, vbLf)
Read suserid one by one en putted in a array
---------------------------------------------
For i = 0 To UBound(initialArray)
Debug.Print initialArray(i)
Next
' Call funtion Routine
'--------------------------
FinalArray() = DeleteDoubleElement(initialArray)
End sub
======================================================================================================================
Private Function DeleteDoubleElement(ByRef ReceivedArray()) As String()
Dim col As Object, i As Integer, ReturnedArray() As String
Set col = CreateObject("Scripting.Dictionary")
For i = 0 To UBound(ReceivedArray)
If Not col.Exists(CStr(ReceivedArray(i))) Then col.Add CStr(ReceivedArray(i)), 1
Next
ReDim ReturnedArray(col.Count - 1)
i = 0
For Each Item In col
ReturnedArray(i) = Item
i = i + 1
Next
Set col = Nothing
DeleteDoubleElement = ReturnedArray
End Function