AllExperts > Experts 
Search      

VB.NET

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More VB.NET Answers
Question Library

Ask a question about VB.NET
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Brandon Drake
Expertise
I can answer questions regarding the Graphics object, file access, general optimization, printing (on paper), user controls, program mathematics, the registry, creating macros, processes, and fundamental or basic questions. I have made a few asp.net pages but I do not know the language extensively. I have not done much work with databases but I have created my own database systems.

Experience
I have been programming with visual basic for 6 years. In all I have written programs in about 8 programming languages, although, I only know about 3 well. I have written a few applications but mainly I like to write programs for fun.

 
   

You are here:  Experts > Computing/Technology > Basic > VB.NET > boolean function

Topic: VB.NET



Expert: Brandon Drake
Date: 5/19/2006
Subject: boolean function

Question
Dear Sir,

Need your explaination to understand the following Boolean function. Thanks in advance.

*********************************************************
Private Sub btnHire_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHire.Click
       If Not ValidateData() Then
           Return
       End If
       Select Case cboEmployeeType.SelectedIndex
           Case -1
               Exit Sub
           Case 0
               HireFullTimeEmployee()
       End Select
End Sub


Private Function ValidateData() As Boolean
Dim dataInValid As Boolean = True
If Not IsDate(txtHireDate.Text) Then
   MsgBox("Hire Date must be a date in the  format MM/DD/YY.", _
MsgBoxStyle.Exclamation, Me.Text)
   dataInValid = False
End If

Return (dataInValid)
End Function
**********************************************************

Let say I hit the btnHire, it will execute the first line - If Not ValidateData() Then.
Afterthat it will go to ValidateData function.
Let say the txtHireDate.Text is in invalid format, so a message prompt and dataInValid=False.
Finally Return(dataInValid) which is False and again back to btnHire.
So what I don't understand is :
Once back to first line - If Not ValidateData() Then , what is the actual return value of this ValidateData()? This line means what ?


Answer
Callisto.

1) You may be confused by this variable name "DataInValid".  The variable is set to True when data is Valid and false when data is invalid.

2) When you are back in the first function, the return value of ValidateData is false.  However, the word "not" reverses this--so "ValidateData"=False but "Not ValidateData()"=True.  Therefore the "Return" inside the if statement will execute.

If you have any more questions or if something above is not clear you can always send me another question.



Good Luck,

Brandon Drake

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.