473,804 Members | 3,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1741
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.goo glegroups.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...@markNOSPA Mrae.comwrote:
"shapper" <mdmo...@gmail. comwrote in message

news:11******** **************@ n33g2000cwc.goo glegroups.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.Fi nd(AddressOf
FindRowByName.S earch)

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...@markNOSPA Mrae.comwrote:
"shapper" <mdmo...@gmail. comwrote in message
news:11******** **************@ n33g2000cwc.goo glegroups.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.Fi nd(AddressOf
FindRowByName.S earch)

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...@gma il.comwrote:
On Mar 13, 10:45 am, "shapper" <mdmo...@gmail. comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"shapper" <mdmo...@gmail. comwrote in message
>news:11******* *************** @n33g2000cwc.go oglegroups.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.Fi nd(AddressOf
FindRowByName.S earch)
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(r ow.Name, Me.RowName)

End Function ' Search

End Class ' FindRowByName

Thanks,
Miguel

Mar 13 '07 #8
On Mar 13, 3:01 pm, David Anton <DavidAn...@dis cussions.micros oft.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.tangib lesoftwaresolut ions.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...@gma il.comwrote:


On Mar 13, 10:45 am, "shapper" <mdmo...@gmail. comwrote:
On Mar 13, 2:22 pm, "Mark Rae" <m...@markNOSPA Mrae.comwrote:
"shapper" <mdmo...@gmail. comwrote in message
news:11******** **************@ n33g2000cwc.goo glegroups.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.Fi nd(AddressOf
FindRowByName.S earch)
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(r ow.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

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

Similar topics

1
5393
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 paragraphs or 2020 characters) when they click on the submit button nothing happens. When I say nothing happens I mean just that, nothing at all happens the page just sits there as if nothing at all happened. If I remove one line for the textarea,...
24
7669
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
6478
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 dao.recordset
17
2133
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
5298
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 .NET component instead of the legacy VB6 component and invokes some methods successfully) until I hit a snag. For one method that is being invoked by the VB6 application, the method takes 2 parameters (string values) and a custom interface. ...
4
4518
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 database (Yes I know, not very good security but for the moment it's enough). Problem is that when I enter a false user/password, I want the code to redirect to another .asp-page which states the user is not valid. Problem lies within the...
9
5054
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 Set(ByVal Value As Image)
9
4555
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 TypeOf obj Is IDisposable Then DirectCast(obj, IDisposable).Dispose()
8
2811
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 the result should be "pass____ what the result is where each underline char is a nothing char. I am about to write a function that will remove the nothing chars butI would like to know what is causing the problem and simply avoid it
0
10558
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10318
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9130
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5503
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5636
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.