By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,105 Members | 2,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,105 IT Pros & Developers. It's quick & easy.

To design Form Template

chandru8
100+
P: 145
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
Oct 19 '07 #1
Share this Question
Share on Google+
4 Replies


Expert 5K+
P: 8,434
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?
Oct 19 '07 #2

chandru8
100+
P: 145
thanks for your reply killer

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

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
Oct 19 '07 #3

P: 67
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,

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Dim col As Collection
  3.  
  4. Private Sub Form_Load()
  5.     'To change control colors
  6.     Dim ctl As Control
  7.     Dim oTB As oTextbox
  8.     Set col = New Collection
  9.     For Each ctl In Me.Controls
  10.         If TypeOf ctl Is TextBox Then
  11.                 Set oTB = New oTextbox
  12.                 Set oTB.TB1 = ctl
  13.                 col.Add oTB
  14.         End If
  15.     Next ctl
  16.     End If
  17. End Sub
  18.  
Then make class module named in this o Textbox
and in this module write the code like this
Expand|Select|Wrap|Line Numbers
  1. Public WithEvents TB1 As TextBox
  2.  
  3. Private Sub TB1_GotFocus()
  4.     With TB1
  5.         .BackColor = RGB(160, 160, 160)
  6.         .ForeColor = vbWhite
  7.         .FontBold = True
  8.     End With
  9. End Sub
  10.  
  11. Private Sub TB1_LostFocus()
  12.     With TB1
  13.         .BackColor = vbWhite
  14.         .ForeColor = vbBlack
  15.     End With
  16. End Sub
  17.  
Hope this will help you.

Regaids
Mayur
Oct 19 '07 #4

Expert 5K+
P: 8,434
my boss told me to create a form template for gotfocus,lostfocus......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.
Oct 20 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.