Databases Reference
In-Depth Information
vector using the specified option buttons. A Worksheet must also be selected from which the data
will be extracted to create the matrix or vector. The drop-down box on the GUI contains the names
of all the Worksheets within the active Workbook. Once the location and type of object to be created
has been determined, the span of cells it occupies must be defined. This can be done manually by
means of the RefEdit control on the GUI, or automatically. To automatically read data into an
object, some assumptions must be made. In this instance, the application assumes that the data
begins in cell A1 and is an (n
m)-sized matrix, where: n = the bottom-most row that contains
data, and m = the right-most column that contains data. The user may also specify the column
delimiter to be utilized. Recall that, in Matlab, either a space or a comma may be used to delineate
row elements in a matrix or vector. Regardless of which delimiter the user chooses, Matlab always
returns its messages delineated with spaces (column elements) and carriage returns (row elements).
The user must select a character identifier to write each matrix or vector to. This is done by
means of a textbox with a spin button control. The textbox can scroll through the alphabet (A-Z)
by pressing the spin buttons. When a vector is chosen, the textbox reverts to lowercase letters, and
when a matrix is chosen, the textbox returns to uppercase letters. This allows the application to
maintain standard matrix- and vector-naming conventions.
The code that accomplishes this task is contained within four subroutines. The first two
subroutines set the starting point for the alphabetic matrix identifier (A = ASCII code 65, a = ASCII
code 97). The starting point is stored in a module-level variable (UorLCase) at the top of the form.
×
Private Sub OB_Matrix_Click()
frm9ShowMatrix.OB_Row.Enabled = False
frm9ShowMatrix.OB_Column.Enabled = False
frm9ShowMatrix.Frame_VType.Enabled = False
UorLCase = 65 'Use Upper Case Identifier for Matrix
If Asc(TextBox_Array.Text) > 90 Then
TextBox_Array.Text = Chr(Asc(TextBox_Array.Text) - 32)
End If
End Sub
Private Sub OB_Vector_Click()
frm9ShowMatrix.OB_Row.Enabled = True
frm9ShowMatrix.OB_Column.Enabled = True
frm9ShowMatrix.Frame_VType.Enabled = True
UorLCase = 97 'Use Lower Case Identifier for Vector
If Asc(TextBox_Array.Text) < 97 Then
TextBox_Array.Text = Chr(Asc(TextBox_Array.Text) + 32)
End If
End Sub
When a spin button is pushed, the ASCII value of the current character in the box is extracted to
the variable
. If
is greater than the starting point
, then the value is
MatRef
MatRef
UorLCase
allowed to decrement as the current letter must be greater than {A or a}. If
is less than
MatRef
(
+ 25), then the value is allowed to increment as the current letter must be less than {Z or z}.
UorLCase
Private Sub SpinButton_SpinDown()
Dim MatRef As Integer
MatRef = Asc(TextBox_Array.Text)
Search WWH ::




Custom Search