Results 1 to 2 of 2

Thread: function

  1. #1
    Join Date
    Dec 1969

    Default function

    Is there any way that in a fuction we declare the arguments or use private access such that we can save the other class variables with out getting changed by a function.

  2. #2
    Join Date
    Dec 1969

    Default Unsure of what you are asking...

    ...but I *think* you are simply saying you want to use a variable in a function and *not* affect a variable of the same name that is outside the function (you specified a class variable, but the answer is the same for global variables).<BR><BR>If that&#039;s what you are asking, the answer is "sure": Just DIM the variable inside the function, and it that name becomes completely private to the function, and the value disappears when the function terminates. NOTE: This *does* mean, though, that you can NOT access the variable of the same name that is outside the function once you do this. <BR><BR>I&#039;ve never tried this in VBS classes, but you *might* be able to circumvent that by using "me.varname" to get the class-level variable. You can certainly use "this.varname" in JS [and Java and C++] functions. There is no way in any of those languages, except C++, to access both the "function scope variable" *and* a global variable, though.<BR><BR>If this isn&#039;t what you mean, try asking again, perhaps with an example?<BR><BR> thing. A function in VBS (and in Java and in JS) can *NOT* have a private variable that retains its value from one invocation of the function to the next. C++ allows this (through "static" variables), but it&#039;s the only one.<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