Visual Basic Tip: 10/09/95


Miscellaneous Tips.
- When unloading a form, consider freeing all the resources associated
  with the form.  VB/Windows retains form level variables and form 
  properties even after a form has been unloaded.  Ex:

  Set frmMine = Nothing


- Use the BeginTrans and CommitTrans statements to speed mass updates 
  to database tables.  This allows VB to write one large chunk of data
  to disk instead of record by record.  Ex:
             
  BeginTrans
  Do While Not tbl.EOF
    i = i + 1
    tbl.edit
    tbl("myfield") = tbl("myfield") & Str$(i)
    tb.update
    tbl.MoveNext
  Loop
  CommitTrans


- In VB, only use global variables when there is no other convenient
  way to share data between forms. You may want to consider storing
  information in a control's Tag property, which can be accessed
  globally using the form.object.property syntax.


- Minimize the number of times a form/object property is referenced.  
  When possible assign the property value to a variable prior to using
  the property multiple times.  This runs much faster!  Ex:

  thetop = frame1.top 
  for i = 0 to 19
    image1.top = thetop + i * 200 
  next

Return to Phil's Web Page

Created by: Philip