| Skype: | TextControlSupport | |
| Orders: | 877-462-4772 |

| Author: | TX Text Control Support Department |
| Language: | Visual Basic 6 |
| Version: | 1.0 |
| Released: | February 17, 2006 |
| Last modified: | January 11, 2008 |
| Requirements: | TX Text Control ActiveX with Visual Basic 6 |
| Download code: | tx_table_loop.zip |
In this sample application, we want to demonstrate how to loop through tables in a document with the TableNext function.
TableNext is different in using it compared to FieldNext, as there are two return values:
i = TXTextControl1.TableNext(i, curTableID)
Variable i is the next enumeration number, that will be used for looping through all tables, and not the related TableID. Instead, TableNext will set curTableID to the corresponding table identifier of the enumeration number.
The function uses enumeration numbers because table identifiers are not unique and can change.
If i has been set to 0, the first table identifier (TableID) and the next enumeration number of the following table are returned.
To use this sample, simply click on File and Create Table Document. A document containing two tables is created on the fly. After that, click on Populate Tables and all cells in all tables in the document are filled with their positions in the tables.
Dim i, j, k, curTableID As Integer i = 0 'Loop for the tables Do 'The TableNext function uses i (Enumeration for the tables) to get curTableID 'Please note that the return value is the enumeration number and NOT the TableID! i = TXTextControl1.TableNext(i, curTableID) 'if the enumeration number is 0, all tables have been processed. If i = 0 Then Exit Do 'Loop through the table rows For j = 1 To TXTextControl1.TableRows(curTableID) 'Loop through the table columns For k = 1 To TXTextControl1.TableColumns(curTableID) 'Set the TableCellText TXTextControl1.TableCellText(curTableID, j, k) = "Row" + Str(j) + ", Column" + Str(k) Next Next Loop
The minimum requirements for this sample application are TX Text Control ActiveX trial version and Visual Basic 6.