Results 1 to 3 of 3

Thread: variables for controls

  1. #1
    Guest
    I want to create a public procedure that I can call from anywhere in my program that will cause a textbox or label backcolor to flash black and white. I got the code for the flashing from VBWorld, but I don't know how to modify the code so that I can tell the procedure in one instance to make a particular textbox backcolor flash and then later instance make another textbox or label backcolor flash.

    It seems that the easiest way is for the flashing procedure to work is to make X flash, where X is a variable for a textbox backcolor or label backcolor. For example, X might be Form1.Text1.Backcolor and then later it might be assigned to be Form2.Label1.Backcolor.

    More accurately, perhaps, how do I create a variable to represent textboxes and labels and their backcolors?

    Thanks

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Code:
    Public Sub FlashControl(C As Control)
    '/// ====================================================================
    '/// By           : Mark Sreeves
    '/// Started      : 27/04/99
    '/// Description  :
    '/// Parameters   :
    '/// Depends on   :
    '/// Side Effects : None
    '/// Notes        :
    '/// ====================================================================
    
        'this flashes the background colour of thre control to draw the users attention to it
        Dim OldColor As Double
        Dim Delay As Double
        Dim X As Integer
        
        On Error Resume Next
        
        OldColor = C.BackColor
        For X = 1 To 3
            C.BackColor = QBColor(12)
            Delay = Timer
                While Timer - Delay < 0.2
                    DoEvents
                Wend
            C.BackColor = OldColor
            Delay = Timer
                While Timer - Delay < 0.2
                    DoEvents
                Wend
        Next X  
    End Sub
    [Edited by Mark Sreeves on 09-19-2000 at 03:13 AM]
    Mark
    -------------------

  3. #3
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    I got your email Tom but I thought I would reply here in case anyone else wants to use the code.

    paste the code above into a Module
    You can then call it from any form in the project like this:

    Code:
    Option Explicit
    'code in form 1
    
    Private Sub Command1_Click()
    FlashControl Label1
    FlashControl Text1
    
    End Sub
    does this all make sense to you?

    [Edited by Mark Sreeves on 09-19-2000 at 03:22 AM]
    Mark
    -------------------

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