Results 1 to 2 of 2

Thread: Handy Little Snippets (1)

  1. #1

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359

    Handy Little Snippets (1)

    This page is currently under construction.
    Please check back often!

    There is also another code snippets page available here

    Contents, in order ;
    00) Create vertical labels
    01) Increment & Decrement Subs
    02) Split a colour into its RGB components
    03) By SLH : Looping through all controls on all loaded forms


    VB Code:
    1. '' Create vertical labels
    2. '' By [URL=http://www.vbforums.com/member.php?s=&action=getinfo&userid=21196]Hack[/URL]
    3. ''
    4. Private Function ShowVertical(ByVal MyString As String) As String
    5.     Dim i As Long
    6.        For i = 1 To Len(MyString)
    7.            If i < Len(MyString) Then
    8.                showVertical = showVertical + Mid$(MyString, i, 1) & vbCrLf
    9.            Else
    10.                showVertical ring = showVertical + Mid$(MyString, i, 1)
    11.            End If
    12.        Next
    13. End Function
    14.  
    15. Private Sub Form_Load()
    16.     Label1.Caption = ShowVertical(Label1.Caption)
    17. End Sub
    18.  
    19.  
    20.  
    21. '' Increment & Decrement Subs
    22. '' By [URL=http://www.vbforums.com/member.php?s=&action=getinfo&userid=23196]GeeSpot[/URL]
    23. ''
    24. Public Sub inc(ByRef n As Long)
    25.     n = n + 1
    26. End Sub
    27. Public Sub dec(ByRef n As Long)
    28.     n = n - 1
    29. End Sub
    30.  
    31.  
    32.  
    33. '' Split a colour into its RGB components
    34. ''
    35. Private Sub longToTriplet(ByVal colLong As Long)
    36.     MsgBox "Red = " & (colLong And &HFF)
    37.     MsgBox "Green = " & ((colLong \ &H100&) And &HFF&)
    38.     MsgBox "Blue = " & ((colLong \ &H10000) And &HFF&)
    39. End Sub
    40.  
    41.  
    42.  
    43. '' Looping through all controls on all loaded forms
    44. '' By [URL=http://www.vbforums.com/member.php?s=&action=getinfo&userid=28721]SLH[/URL]
    45. ''
    46.   Dim frm As Form
    47.   Dim Ctrl As Control
    48.   For Each frm In Forms
    49.       For Each Ctrl In frm
    50.           MsgBox Ctrl.Name
    51.       Next Ctrl
    52.   Next
    Last edited by plenderj; Jun 12th, 2002 at 10:02 AM.
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  2. #2

    Thread Starter
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    * 21-October-2004 - Moved to CodeBank *
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

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