+ Reply to Thread
Results 1 to 4 of 4

user defined function using Array

Hybrid View

  1. #1
    Registered User
    Join Date
    04-03-2007
    Posts
    39

    user defined function using Array

    Good afternoon,
    I have the following user defined function using Array function but it did not work.
    Any ideas will be highly appreciated.
    Dennis


    
    Public Function Cov(Prefix As String)
    
    Dim BIArray As Variant
    Dim PDArray As Variant
    Dim PIPArray As Variant
    
     'Coverage Replace
      BIArray = Array("", "B.I.", "BI-06", "BI-L/T", "BI1", "OTHER BI", "LIAB")
      PDArray = Array("_PD", "DP", "JPD", "P.D, " PD", "  PD", "   PD")
      PIPArray = Array("PI ", "PI", "PIP TRAN", " PIP", "  PIP", "   PIP")
        
      Select Case Prefix
      Case BIArray: Cov = "BI"
      Case PDArray: Cov = "PD"
      Case PIPArray: Cov = "PIP"
      End Select
      
    End Function

  2. #2
    Valued Forum Contributor
    Join Date
    08-26-2006
    Location
    -
    MS-Off Ver
    2010
    Posts
    388
    Don't you need to search through each array in turn? Example for BIArray:
    For i = LBound(BIArray) To UBound(BIArray)
        If BIArray(i) = Prefix Then
            Cov = "BI"
            Exit Function
        End If
    Next i

  3. #3
    Registered User
    Join Date
    04-03-2007
    Posts
    39
    thank you.
    Actually I complexize the question which can be simplified as the following example:

    Case "PI ", "PI", "PIP TRAN", " PIP", " PIP", " PIP": Cov="PIP"

    thanks again the forum.
    Dennis

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,912
    "didn't work" is such a general statement. Can you elaborate? What didn't work? Did it give an error message? What would be a typical value for "prefix"? For a given value of "prefix", what do you expect returned? If it's returning the wrong value, what value is it returning?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1