Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return values 1

Status
Not open for further replies.

WaltLukeIII

Programmer
Jun 28, 2000
199
US
I have written a function that checks some input against a table and if it all comes out correct then I want the function to return a true value and if not I want it to return a false value. <p>Walt III<br><a href=mailto:SAElukewl@netscape.net>SAElukewl@netscape.net</a><br><a href=
 
Walt,<br>All you need to do is Type the function Boolean, then set the Functin value:<br><br>Public Function CheckInput(someinput as String) As Boolean<br>if someinput = 'what it should' Then<br>&nbsp;&nbsp;&nbsp;&nbsp;CheckInput = True[/tab]<br>Else<br>&nbsp;&nbsp;&nbsp;&nbsp;CheckInput = False[/tab]<br>End If<br>End Fucntion<br>--Jim
 
Thanks for the Help Jim <br><br>I put it in and I got it to work by eliminating the '[/tab]' at the end of the set boolean lines what did that part of the code do. <p>Walt III<br><a href=mailto:SAElukewl@netscape.net>SAElukewl@netscape.net</a><br><a href=
 
Jim is correct, however you can narrow the code down to one line using boolean logic:<br><br>Public Function CheckInput(someinput as String) As Boolean<br>&nbsp;&nbsp;&nbsp;CheckInput = someinput = 'what it should'<br>End Function<br><br><br>For example<br><br>If a = b then<br>&nbsp;&nbsp;&nbsp;CheckInput = true<br>Else<br>&nbsp;&nbsp;&nbsp;CheckInput = false<br>End if<br><br>Can Be:<br><br>CheckInput = a = b<br><br>FYI <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
I have heard of boolean logic before but have not dealt with it at all before or even seen an example of it.&nbsp;&nbsp;Can you give me a good place to find some more info on it or even if you have some that you would like to share I would appreciate it. thanks.<br><br> <p>Walt III<br><a href=mailto:SAElukewl@netscape.net>SAElukewl@netscape.net</a><br><a href=
 
Boolean logic is pretty straight forward. Instead of using an If .. Else ..End if Statement, you set the variable or function equal to a boolean equation.<br><br>So instead of saying:<br><br>If x = 6 Then<br>&nbsp;&nbsp;&nbsp;MyVar = True<br>Else<br>&nbsp;&nbsp;&nbsp;MyVar = False<br>End If<br><br>You simply say:<br><br>MyVar = x = 6<br><br>So in essance all you are saying is MyVar will equal True If x = 6, and it will equal False if x does Not = 6.<br><br>Let's say you have a boolean field in a table, that is in a recordset:<br><br>Instead of this:<br><br>If rs!IsSupervisor = True then<br>&nbsp;&nbsp;&nbsp;MyFunction = True<br>Else<br>&nbsp;&nbsp;&nbsp;MyFunction = False<br>End If<br><br>Use This:<br><br>MyFunction = rs!IsSupervisor<br><br>There are many ways to use boolean logic, and the more you use it, the more you will find places to use it.<br><br>I don't know of any place in particular that has information on this, but if I can find something, I will let you know. <p>Jim Lunde<br><a href=mailto:compugeeks@hotmail.com>compugeeks@hotmail.com</a><br><a href= Application Development
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top