Exercise 2– Optimising Code for Faster Execution

Speed of execution is often important in computer-processed tasks. The Current file has many inefficiencies that could be improved for faster execution. One of the main inefficiencies is the reloading of the parent hull form for each iteration.

 

Try improving the execution speed by making these alterations.

·   Modify the code so that the control point data for the parent hull is read into an array or a set excel cells. After each iteration move the control points back to their original locations, using data stored in the control point array.

·   Create a surface list and access the surfaces using the list object.

Hints

To find how long each section of code is taking to execute, use the VBA.Timer property. An example is shown below.

 

Sub UsingTimer()

Dim TimeIn As Long

 

TimeIn = VBA.Timer

 

'-------------

'Code Segment Here

'-------------

 

MsgBox "Execution Time was " & VBA.Timer - TimeIn

 

End Sub

 

For more information on creating and using lists, see the example file Importing Markers into AutoCAD. This file uses list objects to export markers from Maxsurf.