I am getting the error
Function 'Login' doesn't return a value on all code paths. Are you missing a 'Return' statement?
which I understand to a certain extent from viewing various questions on Stack Overflow. My confusion is that I have a return value for all code paths - don't I?
Public Function Login(Username As String, Password As Integer) As Integer
Dim tableAdapter As New AcquisitionPortalDataSetTableAdapters.ITVF_LoginLogoutTableAdapter
Dim dt As DataTable = tableAdapter.GetData(Username, Convert.ToInt32(Password))
Try
If dt IsNot Nothing AndAlso dt.Rows.Count > 0 Then
For Each dr In dt.Rows
If dr("LAN").ToString = Username AndAlso Convert.ToInt32(dr("Code")) = Password Then
GlobalVariables.iUserType = Convert.ToInt32(dr("Code"))
GlobalVariables.iUserID = Convert.ToInt32(dr("ID"))
Return 1
Else
Return 0
End If
Next
Else
Return 0
End If
Catch
Return 0
End Try
End Function
I've gone over this many times and each statement can be evaluated as far as I can tell. Can anyone advise otherwise, ideally with a brief explanation if possible, so I understand for the future?
Login = 0at the very first line in function.