Re: Microsoft.VisualBasic.Strings.Len() works, but Len() does not

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



"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.


.



Relevant Pages

  • Re: No exceptions?
    ... categorize what kind of exceptions a language should support in order ... to allow more adequate relvar manipulation such as union inter relvar ... I personally believe that listing the number of exceptions ... Syntax exceptions involving 2 relvars should be determined at compile ...
    (comp.databases.theory)
  • Re: How to be a good programmer?
    ... > php and c their syntax are same. ... > mind to map other programming language is the best. ... With few exceptions, alas, this is not so. ... The really important books are ...
    (comp.programming)
  • No exceptions?
    ... This little puzzle is prompted by my distaste for exceptions. ... In a language such as TTM Algebra, I wonder if they can be avoided in theory. ... By 'avoided' I mean in the sense of avoiding direct language support for them - an implementation might prefer to give ways to detect them outside of specific language syntax. ...
    (comp.databases.theory)
  • No exceptions?
    ... This little puzzle is prompted by my distaste for exceptions. ... language such as TTM Algebra, I wonder if they can be avoided in theory. ... Syntax exceptions - An expression "x join y" might be a valid syntax ...
    (comp.databases.theory)
  • Re: Looking for volunteers for XL
    ... the form of a notation in an extensible language ... Similarly, in XL, tree rewrites are easily ... XL does not encourage syntax changes. ...
    (comp.compilers)