Default Boolean variable value set to "True" instead of "False"

pkh

New Member
Joined
Nov 23, 2011
Messages
21
Hi,

I've read that the default valuie of a Boolean variable is set to "False". However, i have the following piece if code where the default value seems to be "True".

Code:
Function checkForFree(longTr As Boolean, opType As Integer, goingS As Boolean, curZone As Zone) As Facility
 
' rest of code

In the above code, longTr is false but goingS is True. How is that possible.
I've searched everywhere else in the codes (including all the class modules) but cant seem to find the variable goingS anywhere else.

I've searched using CTRL+F. is there a better way of searching within the codes, since this way i cant even see if there is a mistake in what I type in when looking for something.

Any help appreciated.

Pk
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi Pk,

Since goingS is a required parameter to a function, a "default value" isn't really applicable. The only way for goingS to have a value at all is for the checkForFree function to be called. When that function is called, the "initial value" will be the value assigned to that parameter.

Regarding looking for goingS using CTRL+F, that won't necessarily find the code where this function is being called. One could call the function like the two examples below without using the goingS parameter's variable name...

Rich (BB code):
Set MyFacility = checkForFree(False,6,True, MyZone)

Rich (BB code):
Dim blFound as Boolean
blFound=True
Set MyFacility = checkForFree(False,6,blFound, MyZone)
checkForFree

You should be able to do a CTRL+F search of your entire VBA Project for instances of the phrase "checkForFree" to help you to track down the source of that initial value.
 
Upvote 0
Jerry,
Thanks a lot for the excellent answer. i looked through the code and sure enough now I can see how goingS get the value "true" because the function CheckForFree gets called earlier in the code. Your answer has also made my understanding of functions better.

thanks,
PK
 
Upvote 0

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top