Article ID: 137182
Article Last Modified on 2/12/2000
thisform.test(1)="" && No spaces between the quotation marks
test(1)Then add the following code to the Load event:
thisform.test(1)="" && This assigns the data type to character.If you run the form at this time, you will observe that the list box is blank. If you had not set the data type to character in this example, you would have seen the familiar .F. value displayed.
DIMENSION test(1) && The parenthesis are necessary as well as at
least a length of 1.
Open the Debug window (on the Tools menu, click Debug Window). In the left
partition of the Debug window, type the following lines in order:
test(1) ALEN(test) EMPTY(test)The values for these are .F., 1, and .T. respectively. The first line shows you the default data type. The second shows you the length or number of elements (or number of rows in a single-column array) in the array. The third shows you the results from the evaluation of whether the element is empty or not.
test(1)=""The value in the debug window for test(1) changes to "". This tells you that it is now a character data type with no string assigned to it. Now you can apply this to a form in Visual FoxPro.
thisform.test(1)="" && To assign the data type to character.
IF EMPTY(thisform.test(1))
thisform.test(1)=thisform.text1.value
ELSE
x=ALEN(thisform.test)
x=x+1
DIMENSION thisform.test(x)
thisform.test(x)=thisform.text1.value
thisform.list1.requery
ENDIF
thisform.text1.value=""
thisform.text1.setfocus
This code checks for a value in test(1). If it is empty, the code
passes the value from text1 to test(1), the first element of the
array. Otherwise, it gets the length of the array, adds 1 to it,
redimensions the array to the new length, and passes the value of
text1 to it. To refresh the array, it uses the requery method in the
list1 box. Finally, it sets the value in text to "" (blank) and
returns to text1.
=ASORT(thisform.test) && Sorts the values in the array
thisform.text1.value="" && Sets the value of text1 to ""
thisform.text1.setfocus && Puts the cursor back in text1
thisform.list1.refresh && Refreshes the list box
thisform.release && Clears the form from memory and the screen
Additional query words: VFoxWin
Keywords: KB137182