By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,276 Members | 1,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,276 IT Pros & Developers. It's quick & easy.

comparing string to Object - VB6 to VB.Net

P: n/a
Hello,

I am converting an app from VB6 to VB.Net and have
encountered the following problem. I have the following
loop which retrieves objects from a collection of objects.

Dim entry As Domino.NotesViewEntry
Dim obj As Object, str1 As String
....
For Each obj In entry.ColumnValues.ToString
If IsArray(obj) Then
str1 = obj(0) '<---problem with this line - vb6 syntax
Else
str1 = obj.ToString
End If
Next

the error message says Option Strict doesn't allow late
binding. What would be the correct syntax for handling
this?

I also had a problem with entry.ColumnValues (VB6
syntax). I added .ToSting but haven't tried this yet
(hope it works - entry represents a Lotus Notes document
in a Lotus Notes view - equivalent of a record in an rdbms
system).

TIA,
Rich

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Rich" <an*******@discussions.microsoft.com> schrieb
Hello,

I am converting an app from VB6 to VB.Net and have
encountered the following problem. I have the following
loop which retrieves objects from a collection of objects.

Dim entry As Domino.NotesViewEntry
Dim obj As Object, str1 As String
...
For Each obj In entry.ColumnValues.ToString
If IsArray(obj) Then
str1 = obj(0) '<---problem with this line - vb6 syntax
Else
str1 = obj.ToString
End If
Next

the error message says Option Strict doesn't allow late
binding. What would be the correct syntax for handling
this?
I also had a problem with entry.ColumnValues (VB6
syntax). I added .ToSting but haven't tried this yet
(hope it works - entry represents a Lotus Notes document
in a Lotus Notes view - equivalent of a record in an rdbms
system).


If you use ToString, the loop iterates through all chars in the string, so
str1 would have to be declared as Char - and obj(0) wouldn't make sense.
What is the type of the items in entry.ColumnValues?
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

P: n/a
I declared the variable entry as a Domino.NotesViewEntry
object. So entry represents a row of data in a Lotus
Notes View (similar to a record in a Sql Server view) with
columns/fields. In my scenario, the data is all text data
(numeric text, date text, and char text). If I leave
Option Strict off I can use the syntax below, but with
Option Strict on I run into problems, like late binding
issues, entry.ColumnValues is regard as a System.Object
object, etc. I have posted requesting syntax for using
Option Strict on with these issues:
If I leave Option Strict Off I can use the following
syntax to read data from a Lotus Notes application (a
NotesViewEntry object represents a row of data from a
Lotus Notes View - like a record in a sql Server view)
.....
Dim entry As Domino.NotesViewEntry
Dim obj As Object
str1 = entry.ColumnValues(0)
For Each obj In entry.ColumnValues
str1 = obj
.....

But if I turn Option Strict on then I get a "Late Binding
not allowed" error for

str1 = entry.ColumnValues(0)

and "Expression is of type System Object which is not a
collection type" for

For Each obj In entry.ColumnValues
.....

I also tried

Dim obj() As Object = entry.ColumValues

and got the error message that "Option Strict doesn't
allow implicit conversions from System.Object to a 1
dimensional array of System.Object"

But it did allow
Dim obj As Object = entry.ColumnValues

<<

how can I handle this with Option Strict On in vb.Net?

Thanks,
Rich

-----Original Message-----
"Rich" <an*******@discussions.microsoft.com> schrieb
Hello,

I am converting an app from VB6 to VB.Net and have
encountered the following problem. I have the following
loop which retrieves objects from a collection of
objects.
Dim entry As Domino.NotesViewEntry
Dim obj As Object, str1 As String
...
For Each obj In entry.ColumnValues.ToString
If IsArray(obj) Then
str1 = obj(0) '<---problem with this line - vb6 syntax
Else
str1 = obj.ToString
End If
Next

the error message says Option Strict doesn't allow late
binding. What would be the correct syntax for handling
this?


I also had a problem with entry.ColumnValues (VB6
syntax). I added .ToSting but haven't tried this yet
(hope it works - entry represents a Lotus Notes document
in a Lotus Notes view - equivalent of a record in an rdbms system).


If you use ToString, the loop iterates through all chars

in the string, sostr1 would have to be declared as Char - and obj(0) wouldn't make sense.What is the type of the items in entry.ColumnValues?
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.

Nov 20 '05 #3

P: n/a
ISK


"Rich" wrote:
I declared the variable entry as a Domino.NotesViewEntry
object. So entry represents a row of data in a Lotus
Notes View (similar to a record in a Sql Server view) with
columns/fields. In my scenario, the data is all text data
(numeric text, date text, and char text). If I leave
Option Strict off I can use the syntax below, but with
Option Strict on I run into problems, like late binding
issues, entry.ColumnValues is regard as a System.Object
object, etc. I have posted requesting syntax for using
Option Strict on with these issues:
If I leave Option Strict Off I can use the following
syntax to read data from a Lotus Notes application (a
NotesViewEntry object represents a row of data from a
Lotus Notes View - like a record in a sql Server view)
.....
Dim entry As Domino.NotesViewEntry
Dim obj As Object
str1 = entry.ColumnValues(0)
For Each obj In entry.ColumnValues
str1 = obj
.....

But if I turn Option Strict on then I get a "Late Binding
not allowed" error for

str1 = entry.ColumnValues(0) That's true - late binding is not allowed with option explicit on - which kinda sucks :(
anyway - you could use one of these:
str1 = DirectCast(entry.ColumnValues(0), String)
or
str1 = CType(entry.ColumnValues(0), String)
basically, both are casting functions..

and "Expression is of type System Object which is not a
collection type" for

For Each obj In entry.ColumnValues
.....

I also tried

Dim obj() As Object = entry.ColumValues this doesn't work because i dont think entry.ColumnValues is returning an array
and even if it did, you might have to do something like
Dim obj() As Object = entry.ColumValues()
but i'm not really sure about that..however, if entry.ColumnValues is return a
collection of some other objects, i dont think you can directly assign the collection
to an array of objects; i would think that wouldn't work even if you had option
explicit off.
and got the error message that "Option Strict doesn't
allow implicit conversions from System.Object to a 1
dimensional array of System.Object"

But it did allow
Dim obj As Object = entry.ColumnValues the above statement works because in .NET all reference types are natively of type
'Object'; so you can assign any type to an object.
<<

how can I handle this with Option Strict On in vb.Net?

Thanks,
Rich
hope this helps a bit..
-----Original Message-----
"Rich" <an*******@discussions.microsoft.com> schrieb
Hello,

I am converting an app from VB6 to VB.Net and have
encountered the following problem. I have the following
loop which retrieves objects from a collection of

objects.
Dim entry As Domino.NotesViewEntry
Dim obj As Object, str1 As String
...
For Each obj In entry.ColumnValues.ToString
If IsArray(obj) Then
str1 = obj(0) '<---problem with this line - vb6 syntax
Else
str1 = obj.ToString
End If
Next

the error message says Option Strict doesn't allow late
binding. What would be the correct syntax for handling
this?


I also had a problem with entry.ColumnValues (VB6
syntax). I added .ToSting but haven't tried this yet
(hope it works - entry represents a Lotus Notes document
in a Lotus Notes view - equivalent of a record in an rdbms system).


If you use ToString, the loop iterates through all chars

in the string, so
str1 would have to be declared as Char - and obj(0)

wouldn't make sense.
What is the type of the items in entry.ColumnValues?
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.