Solved

vbscript test boolean variable that is function name

Posted on 2015-01-22
9
147 Views
Last Modified: 2015-01-23
Below is my code, how do I test the function name for true or false?  "If A = True" does not work.  Many thanks for any help.

Function A  
   A=true
End Function
0
Comment
Question by:hardrock95
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:leonstryker
ID: 40564854
Ok, why are you testing the 'function name'? Shouldn't you passing a variable into a function to test?
0
 

Author Comment

by:hardrock95
ID: 40564996
I inherited the code.   Is that poor coding practice?
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 40565110
All the above does is assign true to A. Its basically a global constant.  What is this used for?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:hardrock95
ID: 40565142
So, can it be tested for true or false?
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 40565323
From a different place, yes. Something like this:

If A = true Then
   msgbox "Its True!"
Else
  msgbox "Not working!"
End if

Function A  
   A=true
End Function
0
 

Author Comment

by:hardrock95
ID: 40566233
I tried that and it does not work.  Please see original post.
0
 
LVL 29

Accepted Solution

by:
leonstryker earned 500 total points
ID: 40566364
Works for me no problem. Please tell me more about your environment and how you are running the code.  

The easiest way to test this is copy the code above into a blank file and save it as Test.vbs. You can run it by double clicking the that file.
0
 

Author Comment

by:hardrock95
ID: 40566829
That works for me also. Not sure what my issue was.  I am going to close this and indicate you gave the answer.
Thanks a bunch.
0
 

Author Closing Comment

by:hardrock95
ID: 40566833
Solution by leonstryker
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question