• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

VB .Net -- "Nothing" keyword, and how to use it

Schrodinger

Golden Member
As far as I can tell null and empty have both been deprecated in favour of the "Nothing" keyword.

I have an open file dialog box and, there is a sub I wrote to handle it. Now, I want to check that the dialog box selected a file and does not have a null reference (else it will throw an exception like it currently does)

However, I don't know how to do it!

dlgOpen.filename .????. Nothing

I stabbed "is not" "isnt" "not" "<>" etc and it doesn't seem that I can find what I want :/
 
try this:

if dlgOpen.show(blah blah blah) = dialogresult.ok
then
dim filename as string = dlgOpen.filename
else
your exception stuff goes here
end if

p.s. how's your cat? 😉
 
Since FileName is just a string and is a property of the dialog box, can't you just check if dlgOpen.FileName = ""

The Nothing keyword was around in vb 6 as well. An object variable is equal to Nothing if it hasn't been initialized to point to any object yet, or if you have explicitly destroyed the object by saying "Set objWhatever = nothing".
 
Back
Top