This is really silly question.
Dim s As String
s = "the"
s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to
do to make it work in VB.Net)
I have imported this:
imports system.string 12 23574
Dim s As String
s = s.SubString(1, 2)
SubString() is like the SUB() function in VB 6. You can create your own
Right() function using SubString():
Private Function strRight(ByVal s As String, ByVal i As Integer) As String
If Not ((i >= s.Length) Or (s.Length < 1)) Then
s = s.Substring(s.Length - i, i)
End If
Return (s)
End Function
"patang" <pa****@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com... This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
I have imported this:
imports system.string
Oops. Sorry, been too long. SubString() is like MID(), not SUB. DOH!
"Michael C#" <xy*@abcdef.com> wrote in message
news:bX*******************@fe12.lga... Dim s As String s = s.SubString(1, 2)
SubString() is like the SUB() function in VB 6. You can create your own Right() function using SubString():
Private Function strRight(ByVal s As String, ByVal i As Integer) As String If Not ((i >= s.Length) Or (s.Length < 1)) Then s = s.Substring(s.Length - i, i) End If Return (s) End Function
"patang" <pa****@discussions.microsoft.com> wrote in message news:76**********************************@microsof t.com... This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
I have imported this:
imports system.string
patang,
Strange, this give for me no compiling error, what version are you using and
when it is 2003 did you install the SP1.
Cor
If you are coding this in a form, then you are bumping into a namespace
issue. Left and Right in forms pertain to x-axis distances (there is no name
collision with Mid). Try
Microsoft.VisualBasic.Right(s, 2)
which is a fully qualified reference to the string function you want.
I find this irritating too, but you get used to it fairly quickly. In this
particular case, I use mid() more often and use right() and left() less often.
"patang" wrote: This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
I have imported this:
imports system.string
patang,
Strange, this give for me no compiling error, what version are you using and
when it is 2003 did you install the SP1.
Cor
"patang" <pa****@discussions.microsoft.com> schrieb: This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
'Right' is in conflict with a property of your form. Use 'Strings.Right'
instead.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
If you are coding this in a form, then you are bumping into a namespace
issue. Left and Right in forms pertain to x-axis distances (there is no name
collision with Mid). Try
Microsoft.VisualBasic.Right(s, 2)
which is a fully qualified reference to the string function you want.
I find this irritating too, but you get used to it fairly quickly. In this
particular case, I use mid() more often and use right() and left() less often.
"patang" wrote: This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
I have imported this:
imports system.string
"patang" <pa****@discussions.microsoft.com> schrieb: This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
'Right' is in conflict with a property of your form. Use 'Strings.Right'
instead.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried,
Funny normally I just take a piece of a form to test this, now I did it in a
seperated class.
(As you know am I never using this kind of commands because of the First
indexer)
:-)
Cor
Herfried,
Funny normally I just take a piece of a form to test this, now I did it in a
seperated class.
(As you know am I never using this kind of commands because of the First
indexer)
:-)
Cor
Patang,
As the others suggests. Left & Right are properties of Forms. If you attempt
to use the Left & Right functions on a form you will receive this error.
What I normally do is use an import alias in my form class files.
Something like:
Imports VB = Microsoft.VisualBasic
Public Class MainForm
Inherits System.Windows.Forms.Form
...
Public Sub SomeMethod()
Dim s As String
s = "the"
s = VB.Right(s, 2)
End Sub
End Class
The advantage of the import alias "VB = Microsoft.VisualBasic" is that it
will work with all types (classes, modules, enums, ...) in the
Microsoft.VisualBasic namespace.
Hope this helps
Jay
"patang" <pa****@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com... This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
I have imported this:
imports system.string
Patang,
As the others suggests. Left & Right are properties of Forms. If you attempt
to use the Left & Right functions on a form you will receive this error.
What I normally do is use an import alias in my form class files.
Something like:
Imports VB = Microsoft.VisualBasic
Public Class MainForm
Inherits System.Windows.Forms.Form
...
Public Sub SomeMethod()
Dim s As String
s = "the"
s = VB.Right(s, 2)
End Sub
End Class
The advantage of the import alias "VB = Microsoft.VisualBasic" is that it
will work with all types (classes, modules, enums, ...) in the
Microsoft.VisualBasic namespace.
Hope this helps
Jay
"patang" <pa****@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.com... This is really silly question.
Dim s As String s = "the" s = Right(s, 2)
Why this gives me compilation error? (This works in VB6 .. what do I have to do to make it work in VB.Net)
I have imported this:
imports system.string
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: mitsura |
last post by:
Hi,
I have included a small listing. The test program opens a panel and
show a bitmap.
What I want is to when the mouse is over the bitmap...
|
by: dixie |
last post by:
I have been trying to extract the digits between the two / symbols in a
date. For example the date (in Australian format, not US) is 23/12/2004. I...
|
by: A.M |
last post by:
Hi,
Using C#, what is the equivalent of functions Left, Right and Mid that we
had in vb6?
Thanks,
Alan
|
by: Bruce A. Julseth |
last post by:
I have:
If (Microsoft.VisualBasic.Left(TextBox1.Text, 1) = "$") Then
TextBox1.Text = Microsoft.VisualBasic.Right(TextBox1.Text,...
|
by: Ed Chiu |
last post by:
Hi,
Does C# has functions such as replace, left, right, substring for strings?
Without these functions, it's not easy to process strings.
TIA
|
by: James Brown [MVP] |
last post by:
Hi,
I am having trouble understanding how the 'const' modifier affects the
'left-right' rule when deciphering c-declarations:
const int *x; ...
|
by: Chaitanya |
last post by:
Hello, In my Application i want to know when user clicks both the
"Left" and "Right" buttons of the Mouse.
I am getting a number like this...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
| |