How to use Strings in Statistica Visual Basic
Statistica Visual Basic supports the use of text values called strings. Strings can be used either directly or by using string variables. When strings are used directly, they need to be enclosed in double quotes. For example:
Call MsgBox("N Is <= 0",vbExclamation,"Warning")
String variables are designated by either adding a "$" character at the end of the variable name or declaring it as a string data type explicitly. For example:
Dim TextString As String TextString = "N is <= 0"
or
Dim TextString$ TextString$ = "N is <= 0"
This string variable can then be used anywhere strings are expected. For example:
Call MsgBox(TextString$,vbExclamation,"Warning")
Many Statistica Visual Basic operations and functions are defined using strings. For example:
a$ = "Summary for current" b$ = "month" c$ = "quarter" 'TextString1$ becomes "Summary for current month". 'Note the space which was also added to the string. TextString1$ = a$ + " " + b$ 'TextString2$ becomes "Summary for current quarter" TextString2$ = a$ + " " + c$
If TextString1$ > TextString2$ Then MsgBox(TextString1$) Else MsgBox(TextString2$) End If
Dim s As Spreadsheet Set s = ActiveDataSet s.VariableName(5) = "New Fifth Variable Name"
Functions which manipulate strings. The following examples demonstrate substring extraction, string insertion, and uppercase conversion functions for strings:
TargetString$ = Mid(SourceString$, 5, 7)
or
Mid(TargetString$, 5, 7) = SourceString$
Returns the substring of SourceString$ starting at the sixth index (note that array indexing begins at zero, unless Option Base 1 has been declared) for seven characters into TargetString$. It can also assign SourceString$ to the substring in TargetString$ starting at the sixth index for seven characters.
TargetString$ = UCase (SourceString$)
Returns a string from SourceString$ to TargetString$ where all the lowercase letters have been converted to uppercase.
const CompanyName$ = "Statistica"
See also, Passing Lists of Strings to Statistica Visual Basic Functions.