Ok, Ill try and explain this without sounding like a retard.
I have a function that I call that has a select statement inside it which can range from 0 to 12, one of the values of the function will be a number between 0 to 12, in each case statement, there is:
as you can see, each case statement is basiclly alike, cept its a different array thats being redim'd and loaded with valuesCode:Dim MyArray() as String Dim MyArray2() as String --------------------------------------------------------- Function LoadMyArrays(Type, IntText As String, Flag As Integer) Dim strItems() As String Dim i As Integer Dim MyString As String MyString = IntText strItems = Split(MyString, vbCrLf) Case 0 ReDim MyArray(UBound(strItems)) As String For i = 0 To UBound(strItems) MyArray(i) = strItems(i) If Flag = 1 Then retval = Split(MyArray(i), ",") For j = 0 To UBound(retval) If j = 0 Then Set list_item = Form9.ListView1.ListItems.Add(, , retval(j)) Else list_item.SubItems(1) = retval(j) End If Next j End If Next Case 1 ReDim MyArray2(UBound(strItems)) As String For i = 0 To UBound(strItems) MyArray2(i) = strItems(i) If Flag = 1 Then retval = Split(MyArray2(i), ",") For j = 0 To UBound(retval) If j = 0 Then Set list_item = Form9.ListView1.ListItems.Add(, , retval(j)) Else list_item.SubItems(1) = retval(j) End If Next j End If Next
Now, to the question, would it be possible to get rid of the case statement and just pass in a arrayname, possible code
I've tried several different ways with no avail.Code:Dim MyArray() as String Dim MyArray2() as String ------------------------------------------------ Call LoadMyArrays(MyArray, "some,text,here", 0) ------------------------------------------------ Function LoadMyArrays(MyArrayName, IntText As String, Flag As Integer) Dim strItems() As String Dim i As Integer Dim MyString As String MyString = IntText strItems = Split(MyString, vbCrLf) ReDim MyArrayName(UBound(strItems)) As String 'do all the rest of the stuff above
Any help would be great, if you're confused, ignore me
Thanks.




Reply With Quote