Results 1 to 2 of 2

Thread: Deftype

  1. #1

    Thread Starter
    Frenzied Member axion_sa's Avatar
    Join Date
    Jan 2002
    Location
    Joburg, RSA
    Posts
    1,724

    Deftype

    Just found something in MSDN:
    Deftype Statements

    Used at module level to set the default data type for variables, arguments passed to procedures, and the return type for Function and Property Get procedures whose names start with the specified characters.

    Syntax
    DefBool letterrange[, letterrange] . . .
    DefByte letterrange[, letterrange] . . .
    DefInt letterrange[, letterrange] . . .
    DefLng letterrange[, letterrange] . . .
    DefCur letterrange[, letterrange] . . .
    DefSng letterrange[, letterrange] . . .
    DefDbl letterrange[, letterrange] . . .
    DefDec letterrange[, letterrange] . . .
    DefDate letterrange[, letterrange] . . .
    DefStr letterrange[, letterrange] . . .
    DefObj letterrange[, letterrange] . . .
    DefVar letterrange[, letterrange] . . .

    The required letter range argument has the following syntax:
    letter1[-letter2]

    The letter1 and letter2 arguments specify the name range for which you can set a default data type. Each argument represents the first letter of the variable, argument, Function procedure, or Property Get procedure name and can be any letter of the alphabet. The case of letters in letter range isn't significant.

    Remarks
    The statement name determines the data type:

    Statement Data Type
    DefBool Boolean
    DefByte Byte
    DefInt Integer
    DefLng Long
    DefCur Currency
    DefSng Single
    DefDbl Double
    DefDec Decimal (not currently supported)
    DefDate Date
    DefStr String
    DefObj Object
    DefVar Variant

    For example, in the following program fragment, Message is a string variable:

    DefStr A-Q
    . . .
    Message = "Out of stack space."

    A Deftype statement affects only the module where it is used. For example, a DefInt statement in one module affects only the default data type of variables, arguments passed to procedures, and the return type for Function and Property Get procedures declared in that module; the default data type of variables, arguments, and return types in other modules is unaffected. If not explicitly declared with a Deftype statement, the default data type for all variables, all arguments, all Function procedures, and all Property Get procedures is Variant.

    When you specify a letter range, it usually defines the data type for variables that begin with letters in the first 128 characters of the character set. However, when you specify the letter range A–Z, you set the default to the specified data type for all variables, including variables that begin with international characters from the extended part of the character set (128–255).

    Once the range A–Z has been specified, you can't further redefine any sub ranges of variables using Deftype statements. Once a range has been specified, if you include a previously defined letter in another Deftype statement, an error occurs. However, you can explicitly specify the data type of any variable, defined or not, using a Dim statement with an As type clause. For example, you can use the following code at module level to define a variable as a Double even though the default data type is Integer:

    DefInt A-Z
    Dim TaxRate As Double

    Deftype statements don't affect elements of user-defined types because the elements must be explicitly declared.
    Nice, very nice

  2. #2
    Fanatic Member MikkyThomeon's Avatar
    Join Date
    Oct 2002
    Location
    At work...
    Posts
    648

    VB.net

    Do you know if this is supported in VB.Net?? I want to move in that direction soon, or alternatively php

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width