Add to Favorites    Make Home Page 8773 Online  
 Language Categories  
 Our Services  

Home » ASP Home » Math Home » CBit Function


Search Projects & Source Codes:

Title CBit Function
Description CBit converts anything to an integer that is suitable for use with
MS SQL Server bit fields.

CBit ensures that a 1 or 0 will always be returned by the function,
regardless of the data type or value of the input expression.

CBit returns a 0 or 1 value based on the following criteria (see table).
Criteria is applied in the order stated below. Once any criteria
is recognized by CBit, no other criteria will be checked to determine
the value of the bit field. In other words, CBit goes with the first
criteria that matches and then stops testing the variant input and
returns the results of the first applicable test.

Variant Argument CBit Returns
if variant can be converted to sub-type 1
string and is considered alpha-numeric
and if the value is: "on", "true", "y",
or "t"

if variant can be converted to sub-type 0
string and is considered alpha-numeric
and if the value is: "off", "false", "n",
"f", or ""

if variant can be converted to a long 1
value and is greater than 0

if variant can be converted to a long 0
value and is less than 0

if variant is numeric but raises an error 0
when being converted to long

if variant is null, empty or an array 0

if variant is an object and is set to 1
anything other than Nothing

if variant is an object and is set to 0

if data type or value of passed variant 0
argument is not given a value based on
the above criteria

If CBit cannot determine the bit status of a particular variant entry,
CBit always returns 0.
Category ASP » Math
Hits 348164
Code Select and Copy the Code
<% Private Function CBit(ByVal variantIn) Dim re, bTest, bOut bOut = Null On Error Resume Next Set re = New RegExp With re .Global = False .IgnoreCase = True .Pattern = "^([A-Z-_d]+)$" bTest = .test(variantIn) End With Set re = Nothing If Err Then bTest = False On Error GoTo 0 If IsNull(bOut) And bTest Then 'alpha-numeric Select Case CStr(LCase(Trim(variantIn))) Case "on", "true", "y", "t" bOut = 1 Case "off", "false", "n", "f", "" bOut = 0 End Select End If If IsNull(bOut) And IsNumeric(variantIn) Then On Error Resume Next variantIn = CLng(variantIn) If Err Then bOut = 0 Else If variantIn > 0 Then _ bOut = 1 Else bOut = 0 End If On Error GoTo 0 End If If IsNull(bOut) And (IsNull(variantIn) Or _ IsEmpty(variantIn) Or IsArray(variantIn)) Then bOut = 0 If IsNull(bOut) And IsObject(variantIn) Then If variantIn Is Nothing Then _ bOut = 0 Else bOut = 1 End If If IsNull(bOut) Then bOut = 0 CBit = bOut End Function %>

Related Source Codes

Script Name Author
ııııııııııııııııııııı VyomWorld
Resistor color code reader A.Chermarajan.
Telephone Directory dhivya
card swapping game (Mini Project) nityanand
simple hangman-pascalsource Seabert
college dirtectory (Mini Project) msridhar
Poll Application John van Meter
ASP Daily Hit Counter. Tejaskumar Gandhi
To avoid null in asp environment using sql Sami
Maklumbalas webmaster
poll John van Meter
EasyASP Template Engine. TjoekBezoer
Basic Calculator using HTML & Javascript. Patrick M. D Souza
What servers support ASP ? VyomWorld
What is ASP? VyomWorld


Google Groups Subscribe to SourceCodesWorld - Techies Talk

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!

ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page


Google Search


Source Codes is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024, All Rights Reserved.
Page URL:

Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review