473,770 Members | 4,522 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

comparing string to Object - VB6 to VB.Net

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.NotesVie wEntry
Dim obj As Object, str1 As String
....
For Each obj In entry.ColumnVal ues.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.ColumnVal ues (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
3 3989
"Rich" <an*******@disc ussions.microso ft.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.NotesVie wEntry
Dim obj As Object, str1 As String
...
For Each obj In entry.ColumnVal ues.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.ColumnVal ues (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.ColumnVal ues?
--
Armin

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

Nov 20 '05 #2
I declared the variable entry as a Domino.NotesVie wEntry
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.ColumnVal ues 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.NotesVie wEntry
Dim obj As Object
str1 = entry.ColumnVal ues(0)
For Each obj In entry.ColumnVal ues
str1 = obj
.....

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

str1 = entry.ColumnVal ues(0)

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

For Each obj In entry.ColumnVal ues
.....

I also tried

Dim obj() As Object = entry.ColumValu es

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.ColumnVal ues

<<

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

Thanks,
Rich

-----Original Message-----
"Rich" <an*******@disc ussions.microso ft.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.NotesVie wEntry
Dim obj As Object, str1 As String
...
For Each obj In entry.ColumnVal ues.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.ColumnVal ues (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.ColumnVal ues?
--
Armin

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

.

Nov 20 '05 #3
ISK


"Rich" wrote:
I declared the variable entry as a Domino.NotesVie wEntry
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.ColumnVal ues 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.NotesVie wEntry
Dim obj As Object
str1 = entry.ColumnVal ues(0)
For Each obj In entry.ColumnVal ues
str1 = obj
.....

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

str1 = entry.ColumnVal ues(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(entr y.ColumnValues( 0), String)
or
str1 = CType(entry.Col umnValues(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.ColumnVal ues
.....

I also tried

Dim obj() As Object = entry.ColumValu es this doesn't work because i dont think entry.ColumnVal ues is returning an array
and even if it did, you might have to do something like
Dim obj() As Object = entry.ColumValu es()
but i'm not really sure about that..however, if entry.ColumnVal ues 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.ColumnVal ues 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*******@disc ussions.microso ft.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.NotesVie wEntry
Dim obj As Object, str1 As String
...
For Each obj In entry.ColumnVal ues.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.ColumnVal ues (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.ColumnVal ues?
--
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11583
by: Francesco | last post by:
Ciao, I'm new in c++ programming and I've experimented some method to convert real number into c++ string object, at present I've found as best solution use the C command "sprintf": //------------------------------------------------------ #include <iostream> #include <stdlib.h> #include <string> using namespace std;
1
16346
by: Thomas | last post by:
It looks like the String.replace doesn't work in IE6.1. Anyone else has the same problem. I am using newest service package of IE and Win2K. Thanks
6
1390
by: Christopher Benson-Manica | last post by:
<html> <head> <script> var s=String( 'foo' ); alert( s ); s.bar='bar'; alert( s.bar ); </script></head></html> Why does the second alert produce 'undefined'? Are string objects
2
1037
by: cnickl | last post by:
I’m not sure where to post this, so I post it here. It’s more like a VC++.NET / Managed Code problem. Probably easy to fix for you guys. I want to use a String object as a parameter for a function. Here is what it should look like: String *a = "Hallo"; this->SomeClass->FormatString(a); this->label->Text = a;
2
2101
by: Mike Moore | last post by:
does anyone have an example of how to get the connection string object converted to a string variable type in order for me to call a function?
5
1916
by: rengeek33 | last post by:
I am building a SQL statement for Oracle and need one part of it to read: , myvar = null, myvar2 = "1", myvar3 = "0", myvar4 = null, etc. I am constructing this string using the String object with the following code: theSQL.Append(" , myvar = " & FormatValue(MyClass.DB_CHAR1, Me.MyVar))
10
9070
by: lovecreatesbea... | last post by:
Is it correct and safe to compare a string object with "", a pair of quotation marks quoted empty string?If the string object: s = ""; does s contain a single '\'? Is it better to use std::string::size or std::string::empty to deal with this condition? Thank you. string s = ""; if (s == ""); if (s.size == 0); if (s.empty());
3
2449
by: silverburgh.meryl | last post by:
Hi, If I have a std string object , how to convert a STD string object to an integer? Thank you.
1
1421
by: OccasionalFlyer | last post by:
I'm trying to overcome limitations in a function by passing a string object rather than a string primitive. The code to set the string object's attributes, however, seems to have no effect: var msg = new String( 'WARNING: Quiting now will cancel all changes up to this point, ' + 'leaving your schedule as it was when you began this session. ' + 'Are you sure you want to quit?' ); "msg".blink(); "msg".fontsize(7);
8
2715
by: David Lazos | last post by:
Hi All, I use Contains method of String object to determine if a string variable has another string, like that. *************************** ipAddress.Contains("127.0.0") **************************** supposing that, there is a string array like
0
9602
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
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
10071
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
10017
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
8905
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...
0
5326
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...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.