AboutSyed Rizwan Muhammad Rizvi Expertise I can answers questions regarding web based and desktop based programming in VB.Net. Which can include SOAP, XML, Custom Controls, COM Interoperability etc.
Experience Have been working in this specific area for last 2 years previously I was a VB 6 Developer with experties in other languages as well. Total 10 years of programming experience.
Thanks for your kindly reply, still have doubt..Thanks..
If Not ValidateData() Then
Return
so you mean - if Not [False] , then will execute the Return, right? But what is the actual statement that shows - if [True] only can execute the Return? I mean why is it - if [False] cannnot execute Return?
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 the If condition expects a boolean value to perform its task consider the following eg.
if true then
msgbox "This Message Box will be displayed"
else
msgbox "This one should never be displayed"
end if
if you run the above code you will see that the first messagebox will always appear. but if u modify the condition and change true to false you will observe that the second messagebox will start to appear.
This is how the if condition works, if the condition evaluates to true the if portion is executed otherwise it checks for elseif or the goes to the else section.