Set Variable Data Type Statement
The Set Variable Data Type statement sets the default data type for one or more variables.
Format
DefCur varTypeLetters
DefInt varTypeLetters
DefLng varTypeLetters
DefSng varTypeLetters
DefDbl varTypeLetters
DefStr varTypeLetters
DefVar varTypeLetters
The following table describes the arguments that you can use with this method.
Argument | Description |
---|---|
varTypeLetter |
The first letter of a variable name. |
Usage
The VarTypeLetters argument can be one of the following:
Single letter
List of letters that includes a comma to separate each letter
Range of letters
For example, if you specify a-d, then Siebel VB uses letters a, b, c, and d.
The case of the letters is not important, even in a letter range. Siebel VB considers the a-z letter range as all alpha characters, including international characters.
The Deftype statement affects only the code where you specify it. It must precede any variable definition in the code.
To override the Deftype statement, you can use the Global statement or the Declare Variable statement to declare a variable, and then use an As clause or a type character.
For more information, see Variants.
Example
The following example determines the average of bowling scores that the user enters. Because the average variable begins with A, this example defines it as a single-precision, floating point number. It defines the other variables as integers:
DefInt c,s,t
DefSng a
Sub Button_Click
Dim count
Dim total
Dim score
Dim average
Dim msgtext
For count = 0 to 4
score = 180
total = total + score
Next count
average = total/count
msgtext = "Your average is: " &average
End Sub