ISAPLHA and ISDIGIT functions in Visual FoxPro 9

ISALPHA function is one of the powerful functions in Visual FoxPro 9 that can be used to test if the inputted data is a string or character. By default, ISALPHA has a false value and returns a true value when the Expression is a string data. It is very helpful in filtering illegal inputs:

Syntax:
ISALPHA(Expression)

Where;
1. Expression can be a variable, a text, or a control. ISAPLHA can be entered in any capitalization.

Examples:
ISALPHA(“John”)
ISALPHA(strname)
ISALPHA(Thisform.NameTextbox.Value)

To see ISALPHA in action, follow these steps:

1. Click Start>All Programs>Microsoft Visual FoxPro 9.0.
2. Click File>New>Form>New File.
3. Design your interface as follows:



4. Double-click the control named OkButton then enter the following codes:



5.Press F5 to test our sample application.

Another useful input validation function in Visual FoxPro 9.0 is the ISDIGIT function. It works like ISNUMERIC function in PHP wherein it allows you to test whether the input is a numeric data. Just like the ISALPHA function, the default value of is numeric function is false and it returns true whenever the contents of the expression is a numeric value.

Syntax:
IDIGIT (Expression)

Where;
1. Expression can be a variable, a number, or a control. ISDIGIT can be entered in any capitalization.

Examples:
ISDIGIT (“John”)
ISDIGIT (intage)
ISDIGIT (Thisform.AgeTextbox.Value)

The following example demonstrates the capability of ISDIGIT function:

1. Click Start>All Programs>Microsoft Visual FoxPro 9.0.
2. Click File>New>Form>New File.
3. Design your interface as follows:



4. Double-click the OkButton then enter the following:



5. Press F5 to test our sample application.

Those are the two powerful input validation functions in Visual FoxPro 9. Hope you learn something from it. Till next time.

Changing the header text of a grid control in Visual FoxPro 9

By default, grid control gets its header text from the fieldname caption of a record value displayed in a grid column. To change the grid control header text, follow these steps:

1. Click Start > All Programs > Visual FoxPro 9.

2. Click File>New>Table>New File> Type the table name. For the sake of example, use tblNames as a filename>Click Save. Alternatively, you can type CREA tblNames in the command window. Enter the following fieldname captions and data type:



3. Then Click the Ok Button.

4. Press CTRL + F2 to view the command window. Type APPE then press enter. The APPE or APPEND commands pops-up the append window which enables you to add new records.

5. Add the following records:



6. Click the close button [x] to save the inputted records.

7. Create a new form by clicking File>New>Form>New File. Alternatively, type CREA form in the command window then press enter.

8. Click View> Form Control Toolbar(twice) to activate the toolbox window then click and drag a Grid control from the toolbox to your form.

9. Right-click the Grid control on your form>Select builder. A dialog box containing the following options should then appear:



10. Click the [>>] button. This transfers the fieldnames in the Available fields list box to the selected fields list box.

11. Click the layout tab. The following should then appear:



12. Click the grid control’s column header then enter your desired caption in the caption textbox.




13. Click the Ok button to apply the changes then press CTRL + E to run your form. Alternatively, you can click the run [!] icon.