Visual Basic and Visual FoxPro text delimiters

VBA

"double" quotes.

VFP

'single' or "double" quotes or [square brackets]

Common Syntax Notes

Neither FoxPro nor VBA distinguish between a string of text and a character. They use the same data type and delimiters for both.

Visual Basic Syntax Notes

VBA only supports the double quote as a string delimiter so you often find yourself having to use the ASCII code Chr(34) when you want to use the double quote inside a string, typically when wanting to use an SQL command:

strSQL = "SELECT * FROM Customer WHERE name=" & Chr(34) & "O'Leary" & Chr(34)
set rst = rst.openrecordset(strSQL)

Visual FoxPro Syntax Notes

The variety of delimiters in Visual FoxPro make it easy to embed strings inside other strings. Paradoxically, FoxPro needs this flexibility less than Visual Basic because Fox accepts SQL commands as part of its native syntax. There's no need to wrap the SQL and pass it as a string to a DAO method, FoxPro will just execute it directly as a command:

SELECT * FROM Customer WHERE name = "O'Leary"

You might however want to set the where clause of an SQL statement at runtime and then assign that SQL statement to the RowSource property of a control. We've used two types of quote in the SQL already but we can use the third delimiter around the entire string:

this.RowSource = [SELECT * FROM Customer WHERE name = "O'Leary"]

There's no hierarchy between the three delimiters in FoxPro so this alternative would be equally valid.

this.RowSource = "SELECT * FROM Customer WHERE name = [O'Leary]"

Converting text  |  Text functions  |  Concatenation

More tips from Alvechurch Data

More tips from Alvechurch Data

FoxPro TextMerge

Using TextMerge to export text, html or xml files from FoxPro.

Read More

FoxPro TextMerge example

TextMerge code to export FoxPro data to html.

Read More