Solved

vbscript test boolean variable that is function name

Posted on 2015-01-22
9
139 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
A short article about problems I had with the new location API and permissions in Marshmallow
This video teaches viewers about errors in exception handling.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

810 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