To design Form Template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chandru8
    New Member
    • Sep 2007
    • 145

    To design Form Template

    I need to create a form template for Got_focus,Lost_ focus...
    but I have no idea, to design form template.
    Can anyone help me and give some examples? It's urgent.

    Thanks
    Last edited by Killer42; Oct 19 '07, 06:47 AM.
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by chandru8
    I need to create a form template for Got_focus,Lost_ focus...
    but I have no idea, to design form template.
    Can anyone help me and give some examples? It's urgent.
    Do you mean examples of what sort of thing should be put in the event procedures? Or examples showing how one would create a "form template" or what?

    And what version of VB are you using?

    Comment

    • chandru8
      New Member
      • Sep 2007
      • 145

      #3
      thanks for your reply killer

      my boss told me to create a form template for gotfocus,lostfo cus......

      i created like this,
      ‘Got Focus

      Function Got_Focus( String Objectname)

      ‘Code should be written when the Object got the focus
      ‘runs when text box or list box gets the focus

      End Function

      i don't know this is the correct format or not,please correct me . if not i need some examples
      iam using vb6.0

      Comment

      • Mayur2007
        New Member
        • Aug 2007
        • 67

        #4
        Hi,

        I am not exactly getting what u need but i think u are trying to do the things like that on focus / lost focus text box's change the color. if you need this then the write the code like this
        First of all define the following things global,

        Code:
        Option Explicit
        Dim col As Collection
        
        Private Sub Form_Load()
            'To change control colors
            Dim ctl As Control
            Dim oTB As oTextbox
            Set col = New Collection
            For Each ctl In Me.Controls
                If TypeOf ctl Is TextBox Then
                        Set oTB = New oTextbox
                        Set oTB.TB1 = ctl
                        col.Add oTB
                End If
            Next ctl
            End If
        End Sub
        Then make class module named in this o Textbox
        and in this module write the code like this
        Code:
        Public WithEvents TB1 As TextBox
        
        Private Sub TB1_GotFocus()
            With TB1
                .BackColor = RGB(160, 160, 160)
                .ForeColor = vbWhite
                .FontBold = True
            End With
        End Sub
        
        Private Sub TB1_LostFocus()
            With TB1
                .BackColor = vbWhite
                .ForeColor = vbBlack
            End With
        End Sub
        Hope this will help you.

        Regaids
        Mayur

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by chandru8
          my boss told me to create a form template for gotfocus,lostfo cus......i don't know this is the correct format or not
          I think you need to get more details about what your boss wants. Just calling something a "form template" could mean anything.

          Comment

          Working...