English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I want to check if a variable is null. Apparently...

If var1 Is Not Null Then

is no longer supported.

2007-08-15 08:31:39 · 9 answers · asked by DrDebate 4 in Computers & Internet Programming & Design

Null is no longer available in .NET. The replacement is System.DBNull but it doesn't seem to function the same way.

2007-08-15 08:45:18 · update #1

9 answers

The IsNot operator in VB.net is your best bet:

if myVar IsNot Nothing then
...
end if

It is the most portable, IsNull relies on Microsoft.VisualBasic.dll and this is just plain illogical:

if Not myVar Is Nothing
...
end if

Spock would be most displeased. Live long and prosper!

2007-08-15 09:44:40 · answer #1 · answered by Pfo 7 · 0 0

i've got confidence right here line will forestall you from getting into "A" interior the mixture field. inner maximum Sub ComboBox1_KeyPress(ByVal sender As merchandise, ByVal e As equipment.homestead windows.varieties.KeyPressEventArgs) Handles ComboBox1.KeyPress If e.KeyChar = "A" Then e.dealt with = real end Sub

2016-11-12 10:17:03 · answer #2 · answered by ? 4 · 0 0

If var1 <> Null

(If I remember correctly)

2007-08-15 08:36:36 · answer #3 · answered by jimponder 5 · 0 2

If liname.Text IsNot Nothing Then
DoSomething
EndIf

2007-08-15 08:37:51 · answer #4 · answered by mdigitale 7 · 1 0

I believe it is the following:

If Isnull(Var1) = True then

2007-08-15 09:35:58 · answer #5 · answered by Anonymous · 0 1

Try this:

if var1 <> " " then (no space between quotes)

2007-08-15 08:37:02 · answer #6 · answered by Yoi_55 7 · 0 2

hi for vb try this
if not(isnull(myvar) then
......
end if
bye for now

2007-08-15 09:18:13 · answer #7 · answered by has_infoooo 3 · 0 1

If IsDBNull(foo) Then
...
End If

2007-08-15 09:01:35 · answer #8 · answered by Derek F 2 · 0 1

if not ( var is nothing) then
'whatever
End if

2007-08-15 08:41:35 · answer #9 · answered by Phillip B 2 · 1 0

fedest.com, questions and answers