 |
| Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book:
Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 21st, 2008, 12:54 AM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
Extract a digit from specified position
I have number, which consists of 13 digits, and I need to extract 12-th digit.
In VBA I used LEFT function. What function I gotta use in VB 2005?
|
|

May 21st, 2008, 01:53 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
|
|
Can you t ry the following
Dim sInput As String = "SomeStringForExtraction"
Dim sOutput
sOutput = Mid(sInput, 12, 1)
Cheers
Shasur
http://www.dotnetdud.blogspot.com
VBA Tips & Tricks ( http://www.vbadud.blogspot.com)
|
|

May 23rd, 2008, 02:47 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Mid works in .NET.
But you can also use the new Substring() method.
If the name of your string is "s":
Code:
s.Substring(startIndex_As_Integer, length_As_Integer)
' or
s.Substring(12, 1)
How would you use the Left() function? I could see Right(s, 1)...
|
|

June 4th, 2008, 01:05 AM
|
|
Authorized User
|
|
Join Date: Mar 2008
Posts: 74
Thanks: 2
Thanked 0 Times in 0 Posts
|
|
BrianWren, thanks a lot!
But how can I get to know which methods are obsolete and which one are new to VB 2005?
|
|

June 4th, 2008, 08:46 AM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
I don't know of anything that has been removed from the 1.1 to 2.0 .NET upgrade. Of course, there are many thousands of classes and that many more members of those classes so know one could know what's been changed but Microsoft. If a method has been deprecated, it will be marked as such in the framework and you'll get a warning that the class or method is not obsolete. This doesn't necessarily mean you can't use it, but that it's no longer supported and you should upgrade your code. There's always the potential that the next framework upgrade will break on obsolete members.
-Peter
compiledthoughts.com
|
|

June 4th, 2008, 10:26 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Peter,
Can you think of a way to use Left() to obtain the nth character in a string where n <> 1? (Since sektor apparently didnât feel like answering...)
Perhaps he used Result = Left(Right(s, 2), 1)....
|
|

June 4th, 2008, 12:46 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
Basically what you have but the other way around. Use left to get from the start to n, then right.
Right(Left(s, n), 1)
I can't imagine how you'd do it with only Left() though. But my VBA is very rusty.
-Peter
compiledthoughts.com
|
|

June 9th, 2008, 03:30 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
|
|
Now [u]thatâs</u> handy! Kudos Imar!
|
|
 |