Notices

Great community. Great ideas.

Welcome to ASP/Free, a community dedicated to helping beginners and professionals alike in improving their knowledge of Microsoft's development and administration technologies. Sign up today to gain access to the combined insight of tens of thousands of members.

Thread: Assigning a boolean of true or false to VBScript variable...

Results 1 to 4 of 4
Share This Thread →
  1. #1
    zwieback89 is offline Contributing User
    Join Date
    Sep 2006
    Location
    California
    Posts
    766
    Rep Power
    25

    Assigning a boolean of true or false to VBScript variable...

    Hi,

    Is there a way I can assign a value of true or false to a VBScript variable?

    I have a function where I want to initiate a value of false:

    Would this work?

    Code:
    'Determine if the employee is a manager
    Function IsManager(uniqueID)
    		Dim UID
    		UID = uniqueID
    		'Dim returnValue as boolean
    		Dim returrnValue
    		returnValue = False
    
    		'Execute Query and if Query returns non-empty recordset then set the value of returnValue to True
    		Dim rs3, sqlEmp
    		Set rs3 = Server.CreateObject("ADODB.Recordset")
    		sqlEmp = "SELECT OrgStructure.Manager FROM OrgStructure where OrgStructure.Manager = " & UID
    		rs3.open sqlEmp, Conn
    		If rs3.EOF Then
    		  returnValue = False
    		Else
    		  returnValue = True
    		End If
    		IsManager = returnValue
    
    		rs3.Close
    		Set rs3 = Nothing
    End Function

  2. #2
    Yeruhn's Avatar
    Yeruhn is offline Contributing User
    Join Date
    Feb 2004
    Location
    Netherlands
    Posts
    542
    Rep Power
    238
    Sure. No problem. Did your test show a strange result?

  3. #3
    user101 is offline Contributing User
    Join Date
    Nov 2005
    Posts
    409
    Rep Power
    18
    tested and works...only problem i see off-hand is no protection for non numeric numbers feeding the function:

    Code:
    <%
      'Determine if the employee is a manager
    Function IsManager(uniqueID)
    		Dim UID
    		UID = uniqueID
    
                    If isNumeric(UID) Then
                     UID = CINT(UID)                
    		'Dim returnValue as boolean
    		Dim returrnValue
    		returnValue = False
    
    		'Execute Query and if Query returns non-empty recordset then set the value of returnValue to True
    		Dim rs3, sqlEmp
    		Set rs3 = Server.CreateObject("ADODB.Recordset")
    		sqlEmp = "SELECT OrgStructure.Manager FROM OrgStructure where OrgStructure.Manager = " & UID
    		rs3.open sqlEmp, Conn
    		If rs3.EOF Then
    		  returnValue = False
    		Else
    		  returnValue = True
    		End If
    		IsManager = returnValue
    
    		rs3.Close
    		Set rs3 = Nothing
                   End If
    End Function
    
      ' test function
      uniqueID = 23 ' hardcode 
      
       Select Case IsManager(uniqueID)
        Case true
         Response.Write "Is a manager"
        Case Else
         Response.Write "Is NOT a manager"
       End Select  %>

  4. #4
    zwieback89 is offline Contributing User
    Join Date
    Sep 2006
    Location
    California
    Posts
    766
    Rep Power
    25
    I do not get any error pointing to this function...Just wanted to make sure.

    Thanks.

Share This Thread →

Become Part of This Conversation

Join NowFor Free!

Similar Threads

  1. VBscript - AddDate Function using a variable
    By davidagnew in forum Visual Basic Programming
    Replies: 3
    Last Post: September 8th, 2003, 06:21 AM
  2. ASP - vbscript adddate function + variable
    By davidagnew in forum ASP Development
    Replies: 2
    Last Post: September 4th, 2003, 05:15 AM
  3. Accessing VBScript variable from Javascript
    By Steve Schofield in forum ASP Development
    Replies: 3
    Last Post: July 27th, 2001, 08:57 AM
  4. Replies: 3
    Last Post: October 13th, 2000, 11:50 PM
  5. Replies: 2
    Last Post: October 6th, 2000, 12:40 PM

ASP Free Advertisers and Affiliates