Re: Microsoft.VisualBasic.Strings.Len() works, but Len() does not
- From: "Michael D. Ober" <obermd.@.alum.mit.edu.nospam.>
- Date: Mon, 15 Dec 2008 20:20:09 -0700
"rowe_newsgroups" <rowe_email@xxxxxxxxx> wrote in message news:8dfa8bd6-2ef7-415c-a9a2-efb798ca16c9@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On Dec 13, 11:05 am, Tim Daim <t.d...@xxxxxx> wrote:
Can anybody please tell me what I need to do to be able to just type
Len(sMyString) instead of Microsoft.VisualBasic.Strings.Len(sMyString)
When I convert old projects (from VB6 to .NET), Len() works, but if I
create a new VB.NET project, it does not. I set up the references so
that they look exactely like my converted project (with
VisualBasic.Compatibility, etc...), but I must have missed something.
Thank you!
Tim
Above all else, I would highly recommend you drop the VB classic
syntax and programming style as you move into .NET. Not only is
thinking that .NET is the next iteration of VB classic a dangerous
assumption, but using the syntax will make it harder for you to switch
between languages (such as converting a C# sample to something usuable
in VB, or for a future job / project that is written in a different
language).
For this particular scenario, just use the .Length() property of the
string to accomplish the same thing in a cross-language friendly
fashion.
Thanks,
Seth Rowe [MVP]
http://sethrowe.blogspot.com/
==========================================
In this case, you are correct that you can interchange Len(string) with string.Length. The problem is that a lot of the VB functions that have dotNET equivalents are actually a lot smarter than the dotNET versions in that instead of throwing exceptions, they return something that make sense in the context of the language. For instance, the Basic MID$(string, start, length) doesn't throw an exception if start+length > Len(string), but string.substr(start, length) does.
Mike Ober.
.
- References:
- Microsoft.VisualBasic.Strings.Len() works, but Len() does not
- From: Tim Daim
- Re: Microsoft.VisualBasic.Strings.Len() works, but Len() does not
- From: rowe_newsgroups
- Microsoft.VisualBasic.Strings.Len() works, but Len() does not
- Prev by Date: Re: Moving the Mouse Pointer
- Next by Date: Re: INI file
- Previous by thread: Re: Microsoft.VisualBasic.Strings.Len() works, but Len() does not
- Next by thread: Unicode to UTF8-String
- Index(es):
Relevant Pages
|