Return Null Nothing for validation purpose
Posted on 2003-12-08
Let say I have the following simple code.
newStudent = Nothing
If Not IsNothing(newStudent) Then
Console.WriteLine("They is something") <-- This is printed
Console.WriteLine("They is nothing")
I need to do the above so let say when the user enter an invalid data, the fuction will return nothing so that I know the function has detected an error e.g. newStudent = GetStudentDetails() in user input and therefore return nothing so that my calling program will reject the entry.
But the above does not work, even when newStudent is nothing which indicate that they is nothing it still say they is something, help, any alternative method is welcome.