Re: Nullable object types

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



As I said, you also have to correctly type your property :
Private _ID As Nullable(Of Integer)

Public Property ID() As Nullable(Of Integer)

Get

Return _ID

End Get

Set(ByVal value As Nullable(Of Integer))

_ID = value

End Set

End Property

You can then set the property to nothing :
Me.ID = 1234

Me.ID = Nothing

MsgBox(Me.ID.HasValue)


--
Patrice

"Nemisis" <darrens2005@xxxxxxxxxxx> a écrit dans le message de news:
1155923166.441551.104540@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Patrice wrote:
Try :
Me.ID = Nothing

MsgBox(Me.ID.HasValue)



Use Option Strict so that youi see you should make the propery
IsNullable(Of
Integer) instead of just Object...


--
Patrice

"Nemisis" <darrens2005@xxxxxxxxxxx> a écrit dans le message de news:
1155915967.692120.253820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi everyone, i have been stressing over this for the past hour or so,
and just cannot figure it out, sorry if i am being stupid, but it is a
friday! lol

I have the following

Private _ID as nullable (Of integer)

Public Property ID()
Get
Return _ID
End Get
Set(ByVal value)
_ID = value
End Set
End Property

If i write
Me.ID = 1234

then the value in the debugger seems to update, great.

But how do i get it back to null again? If i set ID = DBNull.Value, i
get a build error. If i set ID = Nothing, then in the debugger, it
says "Nullable object must have a value".

If i am missing the point and being stupid, i do apoligise, i just
really need to get this done.

I have tried setting the property to nothing and that still doesnt
work. ???


.



Relevant Pages

  • Nullable object types
    ... Public Property ID ... then the value in the debugger seems to update, ... says "Nullable object must have a value". ... If i am missing the point and being stupid, i do apoligise, i just ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: DC another Problem
    ... > Private PointsDraw As ClassPoints ... > Private Sub Command1_Click ... > Dim p As Classpoint ... > Public Property Let X ...
    (microsoft.public.vb.winapi.graphics)
  • Re: Getting Windows Display Name
    ... Private Type WKSTA_USER_INFO_1 ... usri3_script_path As Long 'Pointer to a Unicode string specifying the path for the user's logon script file. ... Dim bufptr As Long ... Public Property Get PasswordAgeAs Long ...
    (microsoft.public.access.modulesdaovba)
  • Re: DC another Problem
    ... >>Private PointsDraw As ClassPoints ... >>End Sub ... >>Dim p As Classpoint ... >>Public Property Let X ...
    (microsoft.public.vb.winapi.graphics)
  • PictureBox replacement for classes
    ... Private Type BITMAP ... Private Declare Function StretchBlt Lib "gdi32" _ ... Private Sub Class_Initialize ... Public Property Let Picture ...
    (microsoft.public.vb.general.discussion)