Microsoft.VisualBasic.String.Left

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have two questions with regards to the LEFT function.

I ran into a problem with the LEFT function today. I knew it was a valid
Function, but when I tried to use it, it was getting interpreted as the LEFT
location of a control or something like that, instead of the LEFT function.
(I want to extract the left portion of a string). Anyway, I knew what I
needed was to find out what IMPORTS I was missing. After finding a posting on
MSDN that spoke about a similar issue, I realized I did not need an imports,
but I need to refer to it like Microsoft.VisualBasic.String.Left and it
worked fine. In fact, using Microsoft.VisualBasic.String as an import did not
allow me to use just the LEFT function by itself. I'm assuming this si
because there is already another LEFT defined.

Now my questions.

1. I assume there is a better way of doing this now with VB.Net 2005 since I
need to reference it the way I did. Is there a different command I should be
using in VB.Net 2005 in place of the VB6 way of doing it?

2. I know of a method/function I want to use. In this case, it was LEFT.
But, I don't know the namespace I need to include in my Imports section.
Knowing the command I want to use, how can I find out what Imports I need to
reference to use it?

Thanks,
Greg
 
Greg said:
I have two questions with regards to the LEFT function.

I ran into a problem with the LEFT function today. I knew it was a
valid Function, but when I tried to use it, it was getting
interpreted as the LEFT location of a control or something like
that, instead of the LEFT function. (I want to extract the left
portion of a string). Anyway, I knew what I needed was to find out
what IMPORTS I was missing. After finding a posting on MSDN that
spoke about a similar issue, I realized I did not need an imports,
but I need to refer to it like Microsoft.VisualBasic.String.Left and
it worked fine. In fact, using Microsoft.VisualBasic.String as an
import did not allow me to use just the LEFT function by itself. I'm
assuming this si because there is already another LEFT defined.

Now my questions.

1. I assume there is a better way of doing this now with VB.Net 2005
since I need to reference it the way I did. Is there a different
command I should be using in VB.Net 2005 in place of the VB6 way of
doing it?


TheString.SubString(0, ...)
2. I know of a method/function I want to use. In this case, it was
LEFT. But, I don't know the namespace I need to include in my
Imports section. Knowing the command I want to use, how can I find
out what Imports I need to reference to use it?

Alt+F12 (or "symbol search" in Edit menu): "Left" <enter>


Armin
 
Greg said:
I have two questions with regards to the LEFT function.

I ran into a problem with the LEFT function today. I knew it was a valid
Function, but when I tried to use it, it was getting interpreted as the
LEFT
location of a control or something like that, instead of the LEFT
function.
(I want to extract the left portion of a string). Anyway, I knew what I
needed was to find out what IMPORTS I was missing. After finding a posting
on
MSDN that spoke about a similar issue, I realized I did not need an
imports,
but I need to refer to it like Microsoft.VisualBasic.String.Left and it
worked fine. In fact, using Microsoft.VisualBasic.String as an import did
not
allow me to use just the LEFT function by itself. I'm assuming this si
because there is already another LEFT defined.

Now my questions.

1. I assume there is a better way of doing this now with VB.Net 2005 since
I
need to reference it the way I did. Is there a different command I should
be
using in VB.Net 2005 in place of the VB6 way of doing it?

2. I know of a method/function I want to use. In this case, it was LEFT.
But, I don't know the namespace I need to include in my Imports section.
Knowing the command I want to use, how can I find out what Imports I need
to
reference to use it?

Thanks,
Greg
The LEFT, RIGHT and MID function all run fine in my copy of VS2005 Pro.
Perhaps you need to reference the Microsoft.Visualbasic library.
 
Thanks for the info on the Symbol Search. I was using the Object Browser and
it seems they both pretty much return the same thing, so I guess I must have
been on the right track. I just have a hard time finding something useful
sometimes using these tools.

Anyway, regarding the SubString method. I typed in my variable,
txtVariable... and SubString did not appear in the listing. Again, I figured
I was missing an Imports and I added System.String as one option. Still it
did not work. Just as I was getting ready to tell you it does not work, I
realized I needed to do it this way. txtVariable.TEXT.SubString(x,y). Now it
works just as needed.

Thanks.

Thanks,
Greg
 
I have two questions with regards to the LEFT function.

I ran into a problem with the LEFT function today. I knew it was a valid
Function, but when I tried to use it, it was getting interpreted as the LEFT
location of a control or something like that, instead of the LEFT function.
(I want to extract the left portion of a string). Anyway, I knew what I
needed was to find out what IMPORTS I was missing. After finding a posting on
MSDN that spoke about a similar issue, I realized I did not need an imports,
but I need to refer to it like Microsoft.VisualBasic.String.Left and it
worked fine. In fact, using Microsoft.VisualBasic.String as an import did not
allow me to use just the LEFT function by itself. I'm assuming this si
because there is already another LEFT defined.

I used to reference the Left function with:

Imports Microsoft.VisualBasic = VB

VB.Left(string, 10)
Now my questions.

1. I assume there is a better way of doing this now with VB.Net 2005 since I
need to reference it the way I did. Is there a different command I should be
using in VB.Net 2005 in place of the VB6 way of doing it?

There is no direct replacement in the .NET framework. You can perform
the same effective function with the .Substring method in the String
class.
2. I know of a method/function I want to use. In this case, it was LEFT.
But, I don't know the namespace I need to include in my Imports section.
Knowing the command I want to use, how can I find out what Imports I need to
reference to use it?

The help file. I just did a search on "left string function" and one
of the the first hits was:

http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.strings.left(VS.80).aspx

Which clearly indicates that the function is referenced in the
Microsoft.VisualBasic namespace.
 
Hello Greg,

According to your description, the symbol Left of Microsoft.VisualBasic
seems collide with another symbol with the same name in your project. As
other community members suggest, we could either use SubString, or
explictily declare the namespace of 'Left' (Microsoft.VisualBasic.Left).

Please let me know if you have any other concern or need anything else.

Sincerely,
Jialiang Ge ([email protected], remove ¡®online.¡¯)
Microsoft Online Community Support

==================================================
For MSDN subscribers whose posts are left unanswered, please check this
document: http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express/Windows Mail, please make sure
you clear the check box ¡°Tools/Options/Read: Get 300 headers at a time¡±
to see your reply promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided ¡°AS IS¡± with no warranties, and confers no
rights.
 
Hi Greg,

Would you mind letting me know the result of the suggestions? If you need
further assistance, feel free to let me know. I will be more than happy to
be of assistance.

Have a great day!

Sincerely,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
When responding to posts, please "Reply to Group" via your newsreader
so that others may learn and benefit from your issue.
=================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Just taking a moment to update you on where I'm at.

Rather than using the LEFT function from the Microsoft.VisualBasic library I
am using the SubString instead. I want to avoid using older VB 6.0 types of
methods and functions when at all possible.
 
Back
Top