Hi Mahares,
1) The value of the number of columns is used quite often in the program so it's much more efficient to use a variable instead of using the value each time because if you need change this value you change it once in the variable and not x times in the program.
Example :
If the number of columns = 10
We could use:
Dim ColumnName(10) As String
Dim ColumnWidth(10) As Int
.
.
For i = 0 To 9
ColumnName(i) = something
ColumnWidth(i) = 50dip
Next
For i = 0 To 9
.
Next
.
.
For i = 0 To 9
.
Next
If we need to change the value we need to change it everywhere in the program, this can become combersome and buggy.
So I prefer using a variable, even for the Dim
Dim NumberOfColumns as Int : NumberOfColumns = 10
Dim ColumnName(NumberOfColumns) As String
Dim ColumnWidth(NumberOfColumns) As Int
.
.
For i = 0 To NumberOfColumns - 1
ColumnName(i) = something
ColumnWidth(i) = 50dip
Next
For i = 0 To NumberOfColumns - 1
.
Next
.
.
For i = 0 To NumberOfColumns - 1
.
Next
Changing the value from 10 to 12 is done in NumberOfColumns = 12 and all the rest you don't care.
2.
Also, when do you DIM MyVar() as opposed to MyVar(X)
You use DIM MyVar(X) when you know the value of X and it will not be changed afterwords in the progam. Eventhough it's still possible to 'redim' an array dimed in Globals with a numer, but all values are set to 0 or "".
You use DIM MyVar()
- when you want to fill it with an array, like:
Dim Days() As String
Days = Array As String("Sunday", "Monday", ...)
- or if you want to redim it somewhere else in the program.
Best regards.