473,386 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Is Nothing problem

Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?

Anyway, this is my row definition and its dependencies:

' Row
Public Structure Row

' -- [Properties] ----

' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells

' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name

End Structure ' Row

' Cell
Public Structure Cell

' -- [Properties] ----

' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property ' Content

' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property ' Culture

End Structure ' Cell

Thanks,
Miguel

Mar 13 '07 #1
16 1705
Structures are value types, so you can use "= Nothing".
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"shapper" wrote:
Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?

Anyway, this is my row definition and its dependencies:

' Row
Public Structure Row

' -- [Properties] ----

' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells

' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name

End Structure ' Row

' Cell
Public Structure Cell

' -- [Properties] ----

' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property ' Content

' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property ' Culture

End Structure ' Cell

Thanks,
Miguel

Mar 13 '07 #2
"shapper" <md*****@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
Mar 13 '07 #3
Actually, "= Nothing" won't work unless you have overloaded the '=' operator
in your structure.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"shapper" wrote:
Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?

Anyway, this is my row definition and its dependencies:

' Row
Public Structure Row

' -- [Properties] ----

' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells

' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name

End Structure ' Row

' Cell
Public Structure Cell

' -- [Properties] ----

' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property ' Content

' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property ' Culture

End Structure ' Cell

Thanks,
Miguel

Mar 13 '07 #4
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message

news:11**********************@n33g2000cwc.googlegr oups.com...
If myRow Is Nothing Then

If myRow = Nothing Then
I have tried that before and it didn't work.

Basically my code is:

Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)

If rBox = Nothing Then ...

I get the error:
Operator '=' is not defined for Rows.Row

Any idea?

Thanks,
Miguel
Mar 13 '07 #5
Even though VB allows the use of "Nothing" with structure types (such as
Int32 for example), it tends to be confusing (and requires overloading the
Equals operator). What you should do instead is have a read only property on
your structure, such as "IsInitialized", which returns true if the instance
is explicitly initialized or populated.
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter
"shapper" wrote:
Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?

Anyway, this is my row definition and its dependencies:

' Row
Public Structure Row

' -- [Properties] ----

' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells

' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name

End Structure ' Row

' Cell
Public Structure Cell

' -- [Properties] ----

' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property ' Content

' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property ' Culture

End Structure ' Cell

Thanks,
Miguel

Mar 13 '07 #6
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...
If myRow Is Nothing Then
If myRow = Nothing Then

I have tried that before and it didn't work.

Basically my code is:

Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)

If rBox = Nothing Then ...

I get the error:
Operator '=' is not defined for Rows.Row

Any idea?

Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?

Mar 13 '07 #7
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
>news:11**********************@n33g2000cwc.googleg roups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel

Here's a question for you: Does your Search method ever return Nothing?
My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.

Anyway, If it helps here is my Predicate class:

' FindRowByName
Public Class FindRowByName

' -- [Properties] -------------------------------------------

' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName
' -- [Methods] -------------------------------------------

' New
Public Sub New(ByVal rowName As String)

' Define class properties
Me.RowName = rowName

End Sub ' New

' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean

' Return comparison value
Return String.Equals(row.Name, Me.RowName)

End Function ' Search

End Class ' FindRowByName

Thanks,
Miguel

Mar 13 '07 #8
On Mar 13, 3:01 pm, David Anton <DavidAn...@discussions.microsoft.com>
wrote:
Even though VB allows the use of "Nothing" with structure types (such as
Int32 for example), it tends to be confusing (and requires overloading the
Equals operator). What you should do instead is have a read only property on
your structure, such as "IsInitialized", which returns true if the instance
is explicitly initialized or populated.
--
David Antonwww.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C#/VB to C++ converter
Instant Python: C#/VB to Python converter

"shapper" wrote:
Hello,
I have a generic list as follows:
Dim rows As New Generic.List(Of row)
Now I have a row:
Dim myRow As row
I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
....
End If
I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"
Any idea what I am doing wrong?
Anyway, this is my row definition and its dependencies:
' Row
Public Structure Row
' -- [Properties] ----
' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells
' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name
End Structure ' Row
' Cell
Public Structure Cell
' -- [Properties] ----
' Content
Private _Content As Object
Public Property Content() As Object
Get
Return _Content
End Get
Set(ByVal Content As Object)
_Content = Content
End Set
End Property ' Content
' Culture
Private _Culture As CultureInfo
Public Property Culture() As CultureInfo
Get
Return _Culture
End Get
Set(ByVal Culture As CultureInfo)
_Culture = Culture
End Set
End Property ' Culture
End Structure ' Cell
Thanks,
Miguel
David,

I am a little bit lost.
You mean that I should create a New Method on my structure which sets
a property IsInitialized to true, being IsInitialized default value
set to false?

And how can that help me?

Remember I am using List.Find to get a row.

Thanks,
Miguel

Mar 13 '07 #9
On Mar 13, 11:46 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:


On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?

My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.

Anyway, If it helps here is my Predicate class:

' FindRowByName
Public Class FindRowByName

' -- [Properties] -------------------------------------------

' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName

' -- [Methods] -------------------------------------------

' New
Public Sub New(ByVal rowName As String)

' Define class properties
Me.RowName = rowName

End Sub ' New

' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean

' Return comparison value
Return String.Equals(row.Name, Me.RowName)

End Function ' Search

End Class ' FindRowByName

Thanks,
Miguel- Hide quoted text -

- Show quoted text -
Okay, I gotcha now. So your FindRowByName method, what is its return
type? And what can it return? Does it ever return Nothing?

Mar 13 '07 #10
On Mar 13, 4:03 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 11:46 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
>news:11**********************@n33g2000cwc.googleg roups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?
My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.
Anyway, If it helps here is my Predicate class:
' FindRowByName
Public Class FindRowByName
' -- [Properties] -------------------------------------------
' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName
' -- [Methods] -------------------------------------------
' New
Public Sub New(ByVal rowName As String)
' Define class properties
Me.RowName = rowName
End Sub ' New
' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean
' Return comparison value
Return String.Equals(row.Name, Me.RowName)
End Function ' Search
End Class ' FindRowByName
Thanks,
Miguel- Hide quoted text -
- Show quoted text -

Okay, I gotcha now. So your FindRowByName method, what is its return
type? And what can it return? Does it ever return Nothing?
Mark,

See 2 threads before. FindRowByName is a class which has a method
Search which returns true or false.

Thanks,
Miguel

Mar 13 '07 #11
On Mar 13, 2:56 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 4:03 pm, "Mike Hofer" <kchighl...@gmail.comwrote:


On Mar 13, 11:46 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?
My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.
Anyway, If it helps here is my Predicate class:
' FindRowByName
Public Class FindRowByName
' -- [Properties] -------------------------------------------
' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName
' -- [Methods] -------------------------------------------
' New
Public Sub New(ByVal rowName As String)
' Define class properties
Me.RowName = rowName
End Sub ' New
' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean
' Return comparison value
Return String.Equals(row.Name, Me.RowName)
End Function ' Search
End Class ' FindRowByName
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Okay, I gotcha now. So your FindRowByName method, what is its return
type? And what can it return? Does it ever return Nothing?

Mark,

See 2 threads before. FindRowByName is a class which has a method
Search which returns true or false.

Thanks,
Miguel- Hide quoted text -

- Show quoted text -
Gah! I'm being especially dense today; sorry about that. It's been a
tough one.

What I'm getting at is whether or not the FIND method is capable of
returning a Nothing value. This is the line I'm interested in:

Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)

It returns a Rows.Row object, which, theoretically is a value (since
structures are value types). But what does it return if there is no
matching value?

I'm honestly not trying to be condescending. I'm just trying to
understanding the code in question. There may be a better way to test
for a match failure.

Again, I'm sorry for being so darned thickheaded today.

Mike

Mar 13 '07 #12
On Mar 13, 8:01 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 2:56 pm, "shapper" <mdmo...@gmail.comwrote:


On Mar 13, 4:03 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 11:46 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
>news:11**********************@n33g2000cwc.googleg roups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?
My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.
Anyway, If it helps here is my Predicate class:
' FindRowByName
Public Class FindRowByName
' -- [Properties] -------------------------------------------
' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName
' -- [Methods] -------------------------------------------
' New
Public Sub New(ByVal rowName As String)
' Define class properties
Me.RowName = rowName
End Sub ' New
' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean
' Return comparison value
Return String.Equals(row.Name, Me.RowName)
End Function ' Search
End Class ' FindRowByName
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Okay, I gotcha now. So your FindRowByName method, what is its return
type? And what can it return? Does it ever return Nothing?
Mark,
See 2 threads before. FindRowByName is a class which has a method
Search which returns true or false.
Thanks,
Miguel- Hide quoted text -
- Show quoted text -

Gah! I'm being especially dense today; sorry about that. It's been a
tough one.

What I'm getting at is whether or not the FIND method is capable of
returning a Nothing value. This is the line I'm interested in:

Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)

It returns a Rows.Row object, which, theoretically is a value (since
structures are value types). But what does it return if there is no
matching value?

I'm honestly not trying to be condescending. I'm just trying to
understanding the code in question. There may be a better way to test
for a match failure.

Again, I'm sorry for being so darned thickheaded today.

Mike
Hi Mike,

No problem ... I am not so good in explaining my problem to.

Anyway, I will try to explain the best I can.

In line:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)

FindRowByName.Seach returns True when it is a match and False when it
is not.

Rows is a generic list of Row. I am using the List.Find command:
http://msdn2.microsoft.com/en-us/library/x0b5b5bc.aspx

As I read in that text:

"Parameters

Match
The Predicate delegate that defines the conditions of the element
to search for.

Return Value
The first element that matches the conditions defined by the
specified predicate, if found; otherwise, the default value for type
T."

So when it is not a match it returns the default value for type T, I
believe in my case, the default value of Row.

Now I wonder what is the default value of Row and how can I check it.

My Row Structure is:

' Row
Public Structure Row

' -- [Properties] ----

' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells

' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name

End Structure ' Row

What do you think I should do?

Thank You for the Help,
Miguel

Mar 13 '07 #13
On Mar 13, 4:42 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 8:01 pm, "Mike Hofer" <kchighl...@gmail.comwrote:


On Mar 13, 2:56 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 4:03 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 11:46 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?
My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.
Anyway, If it helps here is my Predicate class:
' FindRowByName
Public Class FindRowByName
' -- [Properties] -------------------------------------------
' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName
' -- [Methods] -------------------------------------------
' New
Public Sub New(ByVal rowName As String)
' Define class properties
Me.RowName = rowName
End Sub ' New
' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean
' Return comparison value
Return String.Equals(row.Name, Me.RowName)
End Function ' Search
End Class ' FindRowByName
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Okay, I gotcha now. So your FindRowByName method, what is its return
type? And what can it return? Does it ever return Nothing?
Mark,
See 2 threads before. FindRowByName is a class which has a method
Search which returns true or false.
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Gah! I'm being especially dense today; sorry about that. It's been a
tough one.
What I'm getting at is whether or not the FIND method is capable of
returning a Nothing value. This is the line I'm interested in:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
It returns a Rows.Row object, which, theoretically is a value (since
structures are value types). But what does it return if there is no
matching value?
I'm honestly not trying to be condescending. I'm just trying to
understanding the code in question. There may be a better way to test
for a match failure.
Again, I'm sorry for being so darned thickheaded today.
Mike

Hi Mike,

No problem ... I am not so good in explaining my problem to.

Anyway, I will try to explain the best I can.

In line:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)

FindRowByName.Seach returns True when it is a match and False when it
is not.

Rows is a generic list of Row. I am using the List.Find command:http://msdn2.microsoft.com/en-us/library/x0b5b5bc.aspx

As I read in that text:

"Parameters

Match
The Predicate delegate that defines the conditions of the element
to search for.

Return Value
The first element that matches the conditions defined by the
specified predicate, if found; otherwise, the default value for type
T."

So when it is not a match it returns the default value for type T, I
believe in my case, the default value of Row.

Now I wonder what is the default value of Row and how can I check it.

My Row Structure is:

' Row
Public Structure Row

' -- [Properties] ----

' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells

' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name

End Structure ' Row

What do you think I should do?

Thank You for the Help,
Miguel- Hide quoted text -

- Show quoted text -
If you're getting the default value of a Rows.Row, then what you're
getting is the equivalent of this:

Return New Rows.Row()

It's a new structure, with the default constructor called. With the
Rows.Row structure written the way it is, it's difficult to test it
for proper initialization.

Have you considered converting it to a full-fledged class? Doing so
doesn't really introduce all that much overhead, and then you could
easily test it for nothingness. Or is there a compelling reason not to
do so? (If it *was* a class, it's default value would be Nothing.)

Mar 14 '07 #14
On Mar 14, 1:41 am, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 4:42 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 8:01 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 2:56 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 4:03 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 11:46 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
>news:11**********************@n33g2000cwc.googleg roups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?
My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.
Anyway, If it helps here is my Predicate class:
' FindRowByName
Public Class FindRowByName
' -- [Properties] -------------------------------------------
' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName
' -- [Methods] -------------------------------------------
' New
Public Sub New(ByVal rowName As String)
' Define class properties
Me.RowName = rowName
End Sub ' New
' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean
' Return comparison value
Return String.Equals(row.Name, Me.RowName)
End Function ' Search
End Class ' FindRowByName
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Okay, I gotcha now. So your FindRowByName method, what is its return
type? And what can it return? Does it ever return Nothing?
Mark,
See 2 threads before. FindRowByName is a class which has a method
Search which returns true or false.
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Gah! I'm being especially dense today; sorry about that. It's been a
tough one.
What I'm getting at is whether or not the FIND method is capable of
returning a Nothing value. This is the line I'm interested in:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
It returns a Rows.Row object, which, theoretically is a value (since
structures are value types). But what does it return if there is no
matching value?
I'm honestly not trying to be condescending. I'm just trying to
understanding the code in question. There may be a better way to test
for a match failure.
Again, I'm sorry for being so darned thickheaded today.
Mike
Hi Mike,
No problem ... I am not so good in explaining my problem to.
Anyway, I will try to explain the best I can.
In line:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
FindRowByName.Seach returns True when it is a match and False when it
is not.
Rows is a generic list of Row. I am using the List.Find command:http://msdn2.microsoft.com/en-us/library/x0b5b5bc.aspx
As I read in that text:
"Parameters
Match
The Predicate delegate that defines the conditions of the element
to search for.
Return Value
The first element that matches the conditions defined by the
specified predicate, if found; otherwise, the default value for type
T."
So when it is not a match it returns the default value for type T, I
believe in my case, the default value of Row.
Now I wonder what is the default value of Row and how can I check it.
My Row Structure is:
' Row
Public Structure Row
' -- [Properties] ----
' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells
' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name
End Structure ' Row
What do you think I should do?
Thank You for the Help,
Miguel- Hide quoted text -
- Show quoted text -

If you're getting the default value of a Rows.Row, then what you're
getting is the equivalent of this:

Return New Rows.Row()

It's a new structure, with the default constructor called. With the
Rows.Row structure written the way it is, it's difficult to test it
for proper initialization.

Have you considered converting it to a full-fledged class? Doing so
doesn't really introduce all that much overhead, and then you could
easily test it for nothingness. Or is there a compelling reason not to
do so? (If it *was* a class, it's default value would be Nothing.)
I see. Making Row and Cell classes instead of structures.
Then I would have:

Rows as a Generic.List(Of Row)
and
Row as a Generic-List(Of Cell)

This is a possible way.
Rows is a Serializable class because I am using Binary Serialization
to save Rows in a SQL VarBinary table field.

I just have one question:

I believe I just need to make both Row and Cell Serializable as I do
to Rows:

<Serializable()_
Public Class Row
...

Then when I serialize Rows I will also serialize the dependent
classes, i.e., Row and Cell, right?

Just to confirm.

I think turning it to classes is the way to go. Thanks for your tip.

Thanks,
Miguel

Mar 14 '07 #15
On Mar 13, 9:55 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 14, 1:41 am, "Mike Hofer" <kchighl...@gmail.comwrote:


On Mar 13, 4:42 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 8:01 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 2:56 pm, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 4:03 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 11:46 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 3:11 pm, "Mike Hofer" <kchighl...@gmail.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail.comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPAMrae.comwrote:
"shapper" <mdmo...@gmail.comwrote in message
news:11**********************@n33g2000cwc.googlegr oups.com...
If myRow Is Nothing Then
If myRow = Nothing Then
I have tried that before and it didn't work.
Basically my code is:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
If rBox = Nothing Then ...
I get the error:
Operator '=' is not defined for Rows.Row
Any idea?
Thanks,
Miguel
Here's a question for you: Does your Search method ever return Nothing?
My Search method returns true or false. It is a Predicate to be used
under Generic.List Find. So basically I need to check if the Find
command found anything.
Anyway, If it helps here is my Predicate class:
' FindRowByName
Public Class FindRowByName
' -- [Properties] -------------------------------------------
' RowName
Private _RowName As String
Public Property RowName() As String
Get
Return _RowName
End Get
Set(ByVal value As String)
_RowName = value
End Set
End Property ' RowName
' -- [Methods] -------------------------------------------
' New
Public Sub New(ByVal rowName As String)
' Define class properties
Me.RowName = rowName
End Sub ' New
' Search
Public Function Search(ByVal row As BoxRows.Row) As Boolean
' Return comparison value
Return String.Equals(row.Name, Me.RowName)
End Function ' Search
End Class ' FindRowByName
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Okay, I gotcha now. So your FindRowByName method, what is its return
type? And what can it return? Does it ever return Nothing?
Mark,
See 2 threads before. FindRowByName is a class which has a method
Search which returns true or false.
Thanks,
Miguel- Hide quoted text -
- Show quoted text -
Gah! I'm being especially dense today; sorry about that. It's been a
tough one.
What I'm getting at is whether or not the FIND method is capable of
returning a Nothing value. This is the line I'm interested in:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
It returns a Rows.Row object, which, theoretically is a value (since
structures are value types). But what does it return if there is no
matching value?
I'm honestly not trying to be condescending. I'm just trying to
understanding the code in question. There may be a better way to test
for a match failure.
Again, I'm sorry for being so darned thickheaded today.
Mike
Hi Mike,
No problem ... I am not so good in explaining my problem to.
Anyway, I will try to explain the best I can.
In line:
Dim myRow As Rows.Row = allRows.Rows.Find(AddressOf
FindRowByName.Search)
FindRowByName.Seach returns True when it is a match and False when it
is not.
Rows is a generic list of Row. I am using the List.Find command:http://msdn2.microsoft.com/en-us/library/x0b5b5bc.aspx
As I read in that text:
"Parameters
Match
The Predicate delegate that defines the conditions of the element
to search for.
Return Value
The first element that matches the conditions defined by the
specified predicate, if found; otherwise, the default value for type
T."
So when it is not a match it returns the default value for type T, I
believe in my case, the default value of Row.
Now I wonder what is the default value of Row and how can I check it.
My Row Structure is:
' Row
Public Structure Row
' -- [Properties] ----
' Cells
Private _Cells As Generic.List(Of Cell)
Public Property Cells() As Generic.List(Of Cell)
Get
Return _Cells
End Get
Set(ByVal Cells As Generic.List(Of Cell))
_Cells = Cells
End Set
End Property ' Cells
' Name
Private _Name As String
Public Property Name() As String
Get
Return _Name
End Get
Set(ByVal Name As String)
_Name = Name
End Set
End Property ' Name
End Structure ' Row
What do you think I should do?
Thank You for the Help,
Miguel- Hide quoted text -
- Show quoted text -
If you're getting the default value of a Rows.Row, then what you're
getting is the equivalent of this:
Return New Rows.Row()
It's a new structure, with the default constructor called. With the
Rows.Row structure written the way it is, it's difficult to test it
for proper initialization.
Have you considered converting it to a full-fledged class? Doing so
doesn't really introduce all that much overhead, and then you could
easily test it for nothingness. Or is there a compelling reason not to
do so? (If it *was* a class, it's default value would be Nothing.)

I see. Making Row and Cell classes instead of structures.
Then I would have:

Rows as a Generic.List(Of Row)
and
Row as a Generic-List(Of Cell)

This is a possible way.
Rows is a Serializable class because I am using Binary Serialization
to save Rows in a SQL VarBinary table field.

I just have one question:

I believe I just need to make both Row and Cell Serializable as I do
to Rows:

<Serializable()_
Public Class Row
...

Then when I serialize Rows I will also serialize the dependent
classes, i.e., Row and Cell, right?

Just to confirm.

I think turning it to classes is the way to go. Thanks for your tip.

Thanks,
Miguel- Hide quoted text -

- Show quoted text -
As far as I can recall, unless you're doing something spectacular (or
fairly obtuse), you shouldn't have to implement any special code to
serialize the objects once you mark them with the <Serializable()>
attribute. I'm assuming, of course, that you're just using value types
in the classes, or object types that are also marked as
<Serializable()>.

But it's always worth confirming that in the documentation.

The special case is, of course, nested trees of objects or circular
references, which doesn't appear to apply here.

Good luck, and I hope this all turns out well for you. Keep us posted,
and let us know how it turns out!

Mike

Mar 14 '07 #16
shapper wrote:
Hello,

I have a generic list as follows:
Dim rows As New Generic.List(Of row)

Now I have a row:
Dim myRow As row

I tried to check, further in my code, if the row is nothing:
If myRow Is Nothing Then
...
End If

I get an error:
"Is" requires operand that have reference types but this operand has
the value of Rows.Row"

Any idea what I am doing wrong?
A structure is a value type, and can not be Nothing. Nothing is the
keyword VB uses for null.

--
Göran Andersson
_____
http://www.guffa.com
Mar 27 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Pete Mahoney | last post by:
Ok I use a textarea to store data input by the user, and then upon them clicking the submit button I store this data to a database. The problem is once the user inputs too much data (about 3...
24
by: Hardy | last post by:
I'm pretty new in this field. when reading some 70x material, I met with this term but cannot catch its accurate meaning. who can help me? thanks in advance:)~
106
by: xtra | last post by:
Hi Folk I have about 1000 procedures in my project. Many, many of them are along the lines of function myfuntion () as boolean on error goto er '- Dim Dbs as dao.database Dim Rst as...
17
by: Lauren Quantrell | last post by:
OK, so I know to: Dim RS As ADODB.Recordset Set RS = CurrentProject.Connection.Execute("EXEC " & "mySPROCname") 'make all sorts of cool stuff happen here... RS.Close Set RS = Nothing
9
by: Tyler | last post by:
I am attempting to extend a legacy VB6 application by making it use a .NET component written in C# exposed through COM interop. Everything appeared to be going well (VB application creates the...
4
by: Avlan | last post by:
Hi, I'm pretty new with ASP-coding, but I got a simple login working. I let the user enter a username and password and through a SQL-statement I check if there is a corresponding password in the...
9
by: Eric | last post by:
Hi Everyone, I'm writing a UserControl that exposes a property of the type System.Drawing.Image, like this: Public Property DefaultImage() As Image Get Return propDefaultImage End Get...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
8
by: Jeremy Kitchen | last post by:
I have encoded a string into Base64 for the purpose of encryption. I then later decrypted it and converted it back from Base64 the final string returns with four nothing characters. "pass" what...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.