22.01.2015 Views

OpenOffice.org Macros Explained - LibreOffice-NA.US

OpenOffice.org Macros Explained - LibreOffice-NA.US

OpenOffice.org Macros Explained - LibreOffice-NA.US

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

3.8.7. Choose.................................................................................................................74<br />

3.8.8. Select Case...........................................................................................................75<br />

Case expressions........................................................................................................75<br />

If Case statements are easy, why are they frequently incorrect...............................76<br />

Writing correct Case expressions..............................................................................77<br />

3.8.9. While ... Wend.....................................................................................................79<br />

3.8.10. Do ... Loop.........................................................................................................79<br />

Exit the Do Loop.......................................................................................................80<br />

Which Do Loop should I use...................................................................................80<br />

3.8.11. For ... Next.........................................................................................................81<br />

3.8.12. Exit Sub and Exit Function................................................................................83<br />

3.9. Error handling using On Error....................................................................................83<br />

3.9.1. CVErr..................................................................................................................84<br />

3.9.2. Ignore errors with On Error Resume Next..........................................................85<br />

3.9.3. Clear an error handler with On Error GoTo 0.....................................................86<br />

3.9.4. Specify your own error handler with On Error GoTo Label...............................86<br />

3.9.5. Error handlers — why use them........................................................................88<br />

3.10. Conclusion.................................................................................................................90<br />

4. Numerical Routines............................................................................................................91<br />

4.1. Trigonometric functions..............................................................................................92<br />

4.2. Rounding errors and precision....................................................................................94<br />

4.3. Mathematical functions...............................................................................................97<br />

4.4. Numeric conversions...................................................................................................98<br />

4.5. Number to string conversions...................................................................................104<br />

4.6. Simple formatting......................................................................................................104<br />

4.7. Other number bases, hexadecimal, octal, and binary................................................105<br />

4.8. Random numbers .....................................................................................................108<br />

4.9. Conclusion.................................................................................................................109<br />

5. Array Routines..................................................................................................................110<br />

5.1. Array() quickly builds a one­dimensional array with data........................................111<br />

5.2. DimArray creates empty multi­dimensional arrays..................................................113<br />

5.3. Change the dimension of an array.............................................................................114<br />

5.4. Array to String and back again..................................................................................115<br />

5.5. Array inspection functions........................................................................................116<br />

5.6. Conclusion.................................................................................................................119<br />

6. Date Routines....................................................................................................................120<br />

6.1. Retrieve the current date and time............................................................................121<br />

6.2. Dates, numbers, and strings......................................................................................121<br />

6.3. Locale formatted dates..............................................................................................123<br />

6.4. ISO 8601 dates..........................................................................................................123<br />

6.5. Problems with dates..................................................................................................124<br />

iii

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!