Left, Right Functions

  • Thread starter Thread starter Bruce A. Julseth
  • Start date Start date
B

Bruce A. Julseth

I have:

If (Microsoft.VisualBasic.Left(TextBox1.Text, 1) = "$") Then

TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text,
TextBox1.Text.Length - 1)

End If

Adding: Imports Microsoft.VisualBasic

And removing the "Microsoft.VisualBasic" from the Left and Right functions
gives me a compile error.

Why?
 
Bruce A. Julseth said:
I have:
If (Microsoft.VisualBasic.Left(TextBox1.Text, 1) = "$") Then
TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text,
TextBox1.Text.Length - 1)
End If

Adding: Imports Microsoft.VisualBasic
And removing the "Microsoft.VisualBasic" from the Left and Right
functions gives me a compile error.

I agree, it /shouldn't/ give you an error and, I suspect, several attempts
at rebuilding the entire Solution will /probably/ make the problem go
away.

But then so would rewriting the above to use the String class methods,
as in :

If TextBox1.Text.StartWith( "$" ) Then
TextBox1.Text = TextBox1.Text.Substring( 1 )
' OK; it /doesn't/ allow for when the text is /only/ "$" ...
End If

HTH,
Phill W.
 
Bruce A. Julseth said:
I have:

If (Microsoft.VisualBasic.Left(TextBox1.Text, 1) = "$") Then

TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text,
TextBox1.Text.Length - 1)

End If

Adding: Imports Microsoft.VisualBasic

And removing the "Microsoft.VisualBasic" from the Left and Right functions
gives me a compile error.

Why?

Never mind. I just read where these functions must be fully qualified...

Thanks...
 
Phill. W said:
/Where/ did you read that? Just curious ...

Regards,
Phill W.

Here is where I found it:

ms-help://MS.VSCC/MS.MSDNVS/vblr7/html/vafctLeft.htm

Thanks..

Bruce
 
Bruce,

You should have a reference to your Microsoft.VisualBasic namespace which is
when you use VSNet with VBNet as with the import standard set. (See your
project properties for that).
You can than do Right(whatever)

By the way the full path to the right function is
Microsoft.VisualBasic.Strings.Right

Although I prefer the simple
If textbox1.text.substring(0,1) = "$"

I hope this gives some idea's

Cor
 
Cor Ligthert said:
Bruce,

You should have a reference to your Microsoft.VisualBasic namespace which is
when you use VSNet with VBNet as with the import standard set. (See your
project properties for that).
You can than do Right(whatever)

By the way the full path to the right function is
Microsoft.VisualBasic.Strings.Right

Although I prefer the simple
If textbox1.text.substring(0,1) = "$"

I hope this gives some idea's

Cor

Cor:

By "reference to your Microsoft.VisualBasic namespace ", do you mean that I
should have the following:

Imports Microsoft.VisualBasic
..
Then the following should work? It doesn't. I get a compile error when the
web page is compiled

If (Left(TextBox1.Text, 1) = "$") Then

TextBox1.Text = Right(TextBox1.Text, TextBox1.Text.Length - 1)

End If

If this is not what you mean, then I don't understand your reply.

Thanks.

Bruce
 
Bruce,

Normally (I saw now that you are using Visual Studio Net or Visual Studio
Basic), there should be a automaticly reference when you have created a form
project using new project.

That you can see in the solution explorer which is usual a right side. In
that is a (directory) tab References, when you open that you should see all
your refences and in that "Microsoft.VisualBasic". When not, than you can
set it by rightclicking on the tab and do add reference. A terrible box
shows up, however there you will find, select and add it using the Net
references.

Not direct related to that however to avoid that you have to set that long
path before the Right are the imports, that you can set in top of every
program, but also in your project properties (right clicking in that same
solution explorer on the project and than properties). In that is a section
Imports.

There are all the standard imports placed.

I hope this tells it, otherwise feel free to reply again.

Cor
 
Phill. W said:
/Where/ did you read that? Just curious ...

There can be a name clash with a form's 'Left' property, for example.
Nevertheless, you don't need to fully qualify the function name. Specifying
the name of the module containing the 'Left' method ('Strings.Left') is
sufficient in most cases.
 
Bruce,
And removing the "Microsoft.VisualBasic" from the Left and Right functions
gives me a compile error.
Remember that a Form has a Left & Right property that hides the Left & Right
functions.

Normally what I do is use an import alias in my Forms, something like:

Imports VB = Microsoft.VisualBasic
If (VB.Left(TextBox1.Text, 1) = "$") Then

TextBox1.Text = VB.Right(TextBox1.Text,
TextBox1.Text.Length - 1)

End If

Hope this helps
Jay
 
Jay B. Harlow said:
Bruce,
Remember that a Form has a Left & Right property that hides the Left & Right
functions.

Normally what I do is use an import alias in my Forms, something like:

Imports VB = Microsoft.VisualBasic


Hope this helps
Jay

This is a webform (ASP.NET) that I am developing. I should have mentioned
this. With this information, I'm sure many of you will "Ah, but of course"
because the solution was

<%@ Import Namespace = "Microsoft.VisualBasic" %>

Thanks for your help...

Bruce
 
Back
Top