Results 1 to 1 of 1

Thread: [SRC] cFrogUCase.cls [by Mr. Frog ©]

  1. #1

    Thread Starter
    Addicted Member *PsyKE1*'s Avatar
    Join Date
    Jun 2010
    Location
    Spain
    Posts
    243

    Thumbs up [SRC] cFrogUCase.cls [by Mr. Frog ©]

    Hi all!
    Here is my new class to change the case when is necessary.

    Class
    vb Code:
    1. Option Explicit
    2. '======================================================================
    3. ' º Class      : cFrogUCase.cls
    4. ' º Version    : 1.3
    5. ' º Author     : Mr.Frog ©
    6. ' º Country    : Spain
    7. ' º Mail       : [email protected]
    8. ' º Date       : 16/02/2011
    9. ' º Twitter    : http://twitter.com/#!/PsYkE1
    10. ' º Recommended Websites :
    11. '       http://foro.h-sec.org
    12. '       http://visual-coders.com.ar
    13. '       http://InfrAngeluX.Sytes.Net
    14. '======================================================================
    15. Private Declare Sub PutMem4 Lib "msvbvm60" (ByVal Ptr As Long, ByVal Value As Long)
    16. Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Ptr() As Any) As Long
    17. Private Declare Function IsCharLowerA Lib "user32" (ByVal cChar As Integer) As Long
    18. Private Declare Function IsCharAlphaNumericA Lib "user32" (ByVal cChar As Integer) As Long
    19. Private Declare Function SysAllocStringByteLen Lib "oleaut32" (ByVal olestr As Long, ByVal BLen As Long) As Long
    20.  
    21. Private lngAscHeader&(0 To 5)
    22. Private intAsc%()
    23.  
    24. Friend Function CorrectUCase(ByRef strText$) As String
    25. Dim lngLength&, Q&
    26.  
    27.     lngLength = LenB(strText) \ 2
    28.     If lngLength Then
    29.         lngAscHeader(3) = StrPtr(strText)
    30.  
    31.         Do While Q < lngLength
    32.             If IsCharAlphaNumericA(intAsc(Q)) Then
    33.                 If IsCharLowerA(intAsc(Q)) Then intAsc(Q) = intAsc(Q) - 32
    34.                 Exit Do
    35.             End If
    36.             Q = Q + 1
    37.         Loop
    38.  
    39.         Q = Q + 1
    40.         Do While Q < lngLength
    41.             If intAsc(Q) < 64 Then
    42.                 Select Case intAsc(Q)
    43.                     Case 33, 46, 63 '! . ?
    44.                         Do
    45.                             Q = Q + 1
    46.                             Select Case intAsc(Q)
    47.                                 Case 59, 44, 46 '; , .
    48.                                     Q = Q + 1
    49.                                     GoTo Next_:
    50.                             End Select
    51.                         Loop While Q < lngLength And IsCharAlphaNumericA(intAsc(Q)) = 0
    52.  
    53.                         If IsCharLowerA(intAsc(Q)) Then intAsc(Q) = intAsc(Q) - 32
    54.                 End Select
    55.             End If
    56. Next_:      Q = Q + 1
    57.         Loop
    58.  
    59.         PutMem4 VarPtr(CorrectUCase), SysAllocStringByteLen(VarPtr(intAsc(0)), lngLength + lngLength)
    60.     End If
    61. End Function
    62.  
    63. Private Sub Class_Initialize()
    64.     lngAscHeader(0) = &H1&: lngAscHeader(1) = &H2&: lngAscHeader(4) = &H7FFFFFFF
    65.     PutMem4 VarPtrArray(intAsc), VarPtr(lngAscHeader(0))
    66. End Sub
    67.  
    68. Private Sub Class_Terminate()
    69.     PutMem4 VarPtrArray(intAsc), 0&
    70. End Sub

    Example:
    vb Code:
    1. Private Sub Form_Load()
    2. Dim c As New cFrogUCase
    3. Const s  As String = " hi, i'm a frog, you do not believe me? ok, doesn't matters. special thanks to Merri and LaVolpe! you help me a lot."
    4.  
    5.     Debug.Print c.CorrectUCase(s)
    6.  
    7.     Set c = Nothing
    8. End Sub

    Returns:
    Code:
     Hi, i'm a frog, you do not believe me? Ok, doesn't matters. Special thanks to Merri and LaVolpe! You help me a lot.
    See you

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