Visual Basic Tip: 01/22/96

Optimization Tips: For/Next, Null fields, orphaned code, Crystal.

- For/Next Loop: Omit the counter on the Next statement.
  A For/Next loop without the counter is faster.


   For i = 1 To 32000

   Next i


   For i = 1 To 32000


- Detect Null fields in a database field faster.  Use code
  similar to that listed below (instead of using an IF IsNull).


   astr$ = data1.recordset.fields("strfld") & ""


   anum = 0 & data1.recordset.fields("numfld")

- Check the (general) subroutines for orphaned code.  Existing code is
  orphaned (or stranded) when you delete a control from a form.  The
  orphaned code consumes disk space and increase the program's memory

- Crystal Reports: try changing the CRW.INI file to solve disk swapping
  for slow reports.

  MaxRecordMemory = 0

- Crystal Reports: You also may want to create an identically structured
  table (as the source data table) to sql the report data into.  Crystal
  Reports seems to send the entire table and then perform the selection.
  This strategy can greatly increase report speed for reports on a subset
  of a large set of data.
Return to Phil's Web Page

Created by: Philip