Class properties

Results 1 to 2 of 2

Thread: Class properties

  1. #1
    Jeremy Lowery Guest

    Default Class properties

    Does anyone know a good article about VBScript Class properties? For example: What "let" means, and exactly what the difference is between properties and subs and functions. Or, if anyone doesn&#039t mind just explaining it. I understand classes very well (I&#039m a C++ programmer), but I haven&#039t been able to find any documentation concerning class properties.

  2. #2 Guest

    Default RE: Class properties

    Not really my bailiwick, but since nobody else has answered...<BR><BR>"Let" is a keyword left over from the earliest days of BASIC<BR>(the very earliest version at Dartmouth University included<BR>it!). It is completely optional (and was in most BASICs by <BR>about 1970 or 1971). The following pair of statements are<BR>100% identical:<BR><BR> Let salesTax = price * taxRate<BR> salesTax = price * taxRate<BR><BR>In VBS classes, there is a distinction, then, between <BR> Property Let<BR>and<BR> Property Set<BR>which is, essentially, the same as the difference between<BR>assignment of simple values to variables and setting a variable<BR>to reference an object. That is, the same as<BR> Let myVar = 3 * someValue<BR> Set myObjRef = Server.CreateObject("someActiveX.control")<BR>reme mbering that the first line there is 100% the same as<BR> myVar = 3 * someValue<BR><BR>The point is, if you expect to change the value of a class<BR>property that refers to an object, you should use "Property Set"<BR>and otherwise use "Property Let". This all makes sense, as<BR>a "Property Set" is really simply shorthand for "evaluate a<BR>function and *SET* the variable to reference the object returned<BR>from the function."<BR><BR>A "sub" is simply a function that doesn&#039t return anything.<BR>Like declaring a return type of "void" in C/C++. In VBScript,<BR>you can *NOT* put the arguments to a SUB in parentheses unless<BR>you use the CALL keyword. That is, you can&#039t do<BR> mySub( 3, "anything" )<BR>but you *CAN* do<BR> mySub 3, "anything"<BR>or<BR> Call mySub( 3, "anything" )<BR><BR>A sharp-eyed language lawyer will note that you *can* call<BR>a sub that takes only one argument using parentheses:<BR> myOneArgSub( 3 * fooey )<BR><BR>The reason: VBS parses that as<BR> SUBNAME expression<BR>where in this case the expression happens to be<BR> ( 3 * fooey )<BR>because, of course, you can always enclose any expression<BR>in parentheses. This causes confusion to newbies who write<BR>a sub with one arg and call it with parens and then have the<BR>code blow up when they use a two-arg sub.<BR><BR>As for not finding documentation concerning class properties...<BR><BR>Where have you been looking? I got all my info from here<BR><BR><BR>Just go to "Statements" and click on the "Class" statement<BR>and then follow the various links and "see also" references.<BR>It&#039s all there. Maybe not well organized, but it&#039s there.<BR><BR><BR><BR><BR><BR><BR>

Posting Permissions

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