469,275 Members | 1,446 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

Problem with LEFT

I use statements like LEFT(textstring,6) in my app. I have "Imports
Microsoft.VisualBasic" at the top of the code but to use LEFT I have to code
:
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with the message

"Public Overloads Property Left() As Integer has no parameters and its
return type cannot be indexed"

How can I get the VisualBasic version of Left as the default?
--
------------------------------------
Wayne Wengert
wa***@wengert.org
Jul 19 '05 #1
7 7775
Did you use Left as a variable or function name?
"Wayne Wengert" <wa***@wengert.org> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...
I use statements like LEFT(textstring,6) in my app. I have "Imports
Microsoft.VisualBasic" at the top of the code but to use LEFT I have to code :
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with the message

"Public Overloads Property Left() As Integer has no parameters and its
return type cannot be indexed"

How can I get the VisualBasic version of Left as the default?
--
------------------------------------
Wayne Wengert
wa***@wengert.org

Jul 19 '05 #2
Are there other namespaces that implement a "Left". The form in question has
the following namespaces

Imports Microsoft.VisualBasic

Imports System.IO

Imports System.Char ' Allows use of ControlChars.nnnn

Imports System.Data.OleDb

Wayne

"dfsdf" <sd****@sdfsdff.dfs> wrote in message
news:Ob********************@rwcrnsc51.ops.asp.att. net...
Did you use Left as a variable or function name?
"Wayne Wengert" <wa***@wengert.org> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...
I use statements like LEFT(textstring,6) in my app. I have "Imports
Microsoft.VisualBasic" at the top of the code but to use LEFT I have to

code
:
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with the message

"Public Overloads Property Left() As Integer has no parameters and its
return type cannot be indexed"

How can I get the VisualBasic version of Left as the default?
--
------------------------------------
Wayne Wengert
wa***@wengert.org


Jul 19 '05 #3
You don't have to manually import the Microsoft.VisualBasic namespace --
Visual Studio does that implicitly for VB projects. You should be able to
use "Left" (and other VB keywords) automatically, without the Imports...
statement and without using the fully-qualified name.

Your problem looks like a namespace conflict. Try right-clicking on the
Left keyword in the module, and select "Go to definition" -- it'll bring up
the object browser, and highlight the method it's trying to use (the other
Left.)

Just to play Devil's advocate, have you considered using the .Net framework
equivalents for Left and other VB keywords? For example, you could replace
"x = Left(MyString, 5)" with x = MyString.Substring(0, 5). There's nothing
wrong with using the VB functions, but in my opinion it's generally a better
practice to use the .Net equivalents when possible.

Check out these links:

http://msdn.microsoft.com/library/de...et0_update.asp

http://msdn.microsoft.com/vbasic/usi...tinternals.asp

Hope this helps,
Robert Jacobson
"Wayne Wengert" <wa***@wengert.org> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...
I use statements like LEFT(textstring,6) in my app. I have "Imports
Microsoft.VisualBasic" at the top of the code but to use LEFT I have to code :
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with the message

"Public Overloads Property Left() As Integer has no parameters and its
return type cannot be indexed"

How can I get the VisualBasic version of Left as the default?
--
------------------------------------
Wayne Wengert
wa***@wengert.org

Jul 19 '05 #4
Hmmm.. that gets me....

<System.ComponentModel.BrowsableAttribute(False) ,
System.ComponentModel.DesignerSerializationVisibil ityAttribute(0),
System.Windows.Forms.SRCategoryAttribute("CatLayou t"),
System.Windows.Forms.SRDescriptionAttribute("Contr olLeftDescr"),
System.ComponentModel.EditorBrowsableAttribute(0)>

Public Property Left As Integer

Member of System.Windows.Forms.Control

I don't see how to find what control has a "Left" property. I'll check out
the links you provided.

Wayne
"Robert Jacobson" <rj**********************@nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
You don't have to manually import the Microsoft.VisualBasic namespace --
Visual Studio does that implicitly for VB projects. You should be able to
use "Left" (and other VB keywords) automatically, without the Imports...
statement and without using the fully-qualified name.

Your problem looks like a namespace conflict. Try right-clicking on the
Left keyword in the module, and select "Go to definition" -- it'll bring up the object browser, and highlight the method it's trying to use (the other
Left.)

Just to play Devil's advocate, have you considered using the .Net framework equivalents for Left and other VB keywords? For example, you could replace "x = Left(MyString, 5)" with x = MyString.Substring(0, 5). There's nothing wrong with using the VB functions, but in my opinion it's generally a better practice to use the .Net equivalents when possible.

Check out these links:

http://msdn.microsoft.com/library/de...et0_update.asp
http://msdn.microsoft.com/vbasic/usi...tinternals.asp
Hope this helps,
Robert Jacobson
"Wayne Wengert" <wa***@wengert.org> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...
I use statements like LEFT(textstring,6) in my app. I have "Imports
Microsoft.VisualBasic" at the top of the code but to use LEFT I have to

code
:
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with the message

"Public Overloads Property Left() As Integer has no parameters and its
return type cannot be indexed"

How can I get the VisualBasic version of Left as the default?
--
------------------------------------
Wayne Wengert
wa***@wengert.org


Jul 19 '05 #5
Wayne,
Remember Left & Right are a properties of System.Windows.Forms.Control,
System.Windows.Forms.Form inherits from Control.

If you want to use the VB.Left or VB.Right functions within a Form or
UserControl, you need to prefix it with a namespace.

One handy method is to use

Imports VB = Microsoft.VisualBasic

for your import, then you can use VB.Left to call the function.

Hope this helps
Jay
"Wayne Wengert" <wa***@wengert.org> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...
I use statements like LEFT(textstring,6) in my app. I have "Imports
Microsoft.VisualBasic" at the top of the code but to use LEFT I have to code :
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with the message

"Public Overloads Property Left() As Integer has no parameters and its
return type cannot be indexed"

How can I get the VisualBasic version of Left as the default?
--
------------------------------------
Wayne Wengert
wa***@wengert.org

Jul 19 '05 #6
Great tip - didn't know you could do that.

Wayne

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:OV**************@TK2MSFTNGP12.phx.gbl...
Wayne,
Remember Left & Right are a properties of System.Windows.Forms.Control,
System.Windows.Forms.Form inherits from Control.

If you want to use the VB.Left or VB.Right functions within a Form or
UserControl, you need to prefix it with a namespace.

One handy method is to use

Imports VB = Microsoft.VisualBasic

for your import, then you can use VB.Left to call the function.

Hope this helps
Jay
"Wayne Wengert" <wa***@wengert.org> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...
I use statements like LEFT(textstring,6) in my app. I have "Imports
Microsoft.VisualBasic" at the top of the code but to use LEFT I have to

code
:
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with the message

"Public Overloads Property Left() As Integer has no parameters and its
return type cannot be indexed"

How can I get the VisualBasic version of Left as the default?
--
------------------------------------
Wayne Wengert
wa***@wengert.org


Jul 19 '05 #7
guy
re devils advocate - note that the VB string handling
functions are in some but not all cases faster than using
SubString - there is an MS doc that covers this but I
havent got the url to hand

hth

guy
-----Original Message-----
You don't have to manually import the Microsoft.VisualBasic namespace --Visual Studio does that implicitly for VB projects. You should be able touse "Left" (and other VB keywords) automatically, without the Imports...statement and without using the fully-qualified name.

Your problem looks like a namespace conflict. Try right- clicking on theLeft keyword in the module, and select "Go to definition" -- it'll bring upthe object browser, and highlight the method it's trying to use (the otherLeft.)

Just to play Devil's advocate, have you considered using the .Net frameworkequivalents for Left and other VB keywords? For example, you could replace"x = Left(MyString, 5)" with x = MyString.Substring(0, 5). There's nothingwrong with using the VB functions, but in my opinion it's generally a betterpractice to use the .Net equivalents when possible.

Check out these links:

http://msdn.microsoft.com/library/default.asp? url=/library/en-us/dnguinet/html/drguinet0_update.asp
http://msdn.microsoft.com/vbasic/usi...standing/defau lt.aspx?pull=/library/en-
us/dv_vstechart/html/vbtchmicrosoftvisualbasicnetinternals.
asp
Hope this helps,
Robert Jacobson
"Wayne Wengert" <wa***@wengert.org> wrote in message
news:OB**************@TK2MSFTNGP10.phx.gbl...
I use statements like LEFT(textstring,6) in my app. I have "Imports Microsoft.VisualBasic" at the top of the code but to use LEFT I have to
code
:
Microsoft.VisualBasic.Left(sting, integer)

If I code just "Left" it is flagged as an error with

the message
"Public Overloads Property Left() As Integer has no parameters and its return type cannot be indexed"

How can I get the VisualBasic version of Left as the default? --
------------------------------------
Wayne Wengert
wa***@wengert.org

.

Jul 19 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bruce Duncan | last post: by
4 posts views Thread by JesusFreak | last post: by
6 posts views Thread by B McDonald | last post: by
9 posts views Thread by Stephen Melia | last post: by
1 post views Thread by books1999 | last post: by
8 posts views Thread by knoxautoguy | last post: by
pradeepjain
1 post views Thread by pradeepjain | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.