Results 1 to 25 of 25

Thread: [RESOLVED] Writing (advanced?) functions?

Threaded View

  1. #21
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: [RESOLVED] Writing (advanced?) functions?

    I don't know why one would really like to do things like this, but...

    VB Code:
    1. Option Explicit
    2.  
    3. Private Enum LETTERS
    4.     [UC A to Z] = 0
    5.     [LC a to z] = 1
    6. End Enum
    7.  
    8. Private Function Uniq(CaseType As LETTERS) As String
    9.     Select Case CaseType
    10.         Case [UC A to Z]
    11.             Uniq = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    12.         Case [LC a to z]
    13.             Uniq = "abcdefghijklmnopqrstuvwxyz"
    14.     End Select
    15. End Function
    16. Private Sub Form_Load()
    17.     Debug.Print Uniq([UC A to Z])
    18. End Sub

    Spooky.


    Edit!
    And if someone wants to complain about performance, then just make it an array:

    VB Code:
    1. Option Explicit
    2.  
    3. Private Enum LETTERS
    4.     [UC A to Z] = 0
    5.     [LC a to z] = 1
    6. End Enum
    7.  
    8. Private Uniq(1) As String
    9.  
    10. Private Sub InitUniq()
    11.     Uniq([UC A to Z]) = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    12.     Uniq([LC a to z]) = "abcdefghijklmnopqrstuvwxyz"
    13. End Sub
    14. Private Sub Form_Load()
    15.     InitUniq
    16.     Debug.Print Uniq([UC A to Z])
    17. End Sub

    And it works a lot faster.
    Last edited by Merri; Jun 9th, 2006 at 09:31 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width