473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

InStr

Hello Everybody,
Question

instr function will give you the first instance of the finding
so EX:
so your string looks like

string1 = "testing>This is > just a test > testtesttest"
instr(string1,">")

so instr will give me a 8 as a return item
i need to get the last instance
Easy way to do this.

Thanks
Chris
Nov 21 '05 #1
6 3989
Super easy!

Change "Instr" function to "InStrRev " function, which gets the
position, starting from the right side of the string.

:)

Nov 21 '05 #2
Something like this

Untested
Len(mystring) - InStr(StrReverse(mystring), ">")

Richard

"Chris Calzaretta" <cc*********@hotmail.com> wrote in message
news:O9**************@tk2msftngp13.phx.gbl...
Hello Everybody,
Question

instr function will give you the first instance of the finding
so EX:
so your string looks like

string1 = "testing>This is > just a test > testtesttest"
instr(string1,">")

so instr will give me a 8 as a return item
i need to get the last instance
Easy way to do this.

Thanks
Chris

Nov 21 '05 #3
Chris,

When you want to use the Zero indexer ( I assume you don't want it however
to get the answers complete than there is instead of the InStringRev as well
the instruction). Don't expect any advantage from that, than that you are
using the Zero as starting indexer instead of that you get back when it is
on the first position a 1.

dim pos as integer = String1.lastindexof(">")
it gives a -1 when that is not in it.

I hope this helps,

Cor
Nov 21 '05 #4
Chris,

"Chris Calzaretta" <cc*********@hotmail.com> schrieb:
instr function will give you the first instance of the finding
so EX:
so your string looks like

string1 = "testing>This is > just a test > testtesttest"
instr(string1,">")

so instr will give me a 8 as a return item
i need to get the last instance


'Microsoft.VisualBasic.Strings.InStrRev'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Nov 21 '05 #5
"Cor Ligthert" <no************@planet.nl> ha scritto nel messaggio
news:eS**************@tk2msftngp13.phx.gbl...

dim pos as integer = String1.lastindexof(">")


Finally someone that uses the right .Net way instead of the
old-fashoned-VB6-retro-compatibility functions, that aren't OOP and aren't
so fast as native ones.
--
Reporting tool: http://www.neodatatype.net
Nov 21 '05 #6
"Cor Ligthert" <no************@planet.nl> ha scritto nel messaggio
news:#O**************@TK2MSFTNGP14.phx.gbl...

I did nowhere write it is "better", when you see Hefried samples, than he is forever using Mid, Right, Left in that case I would find it very incosequent to use indexof.


:)

I don't care about bad-coded-samples ;)

--
Reporting tool: http://www.neodatatype.net
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: DTB | last post by:
I am trying to convert a complex function from Oracle to SQL Server and have come across Oracle's Instr() function. I see SQL Server has CHARINDEX() which is similar, however it does not provide...
4
by: Gordon | last post by:
Hi; I am trying to extract a substring using a combination of the mid() and Instr() i.e. aString = "Jones, Thomas R, Dr." hold = InStr(1, aString, " ," , 1) newString = Mid(aString, 1,...
3
by: Mary | last post by:
MemberID VID 1002 1001 1003 1002 1004 1003 1005 1003 1007 1001...
4
by: fischerspooner | last post by:
Hi, I'm banging my head against the desk because I can't find a solution for the following simple problem. Case: There is a column in a table that has FamilyName and FirstName(s) in one field....
12
by: rodchar | last post by:
hey all, i'm getting a result that i don't understand i have a string "test1, test2" If InStr("test1") and InStr("test2") Then 'Inside EndIf The inside is not running for some reason. Any...
2
by: Puneet Bhatnagar | last post by:
A textual comparison starting at position 4. Returns 6. MyPos = Instr(4, SearchString, SearchChar, 1) ' A binary comparison starting at position 1. Returns 9. MyPos = Instr(1, SearchString,...
3
by: lstrudeman | last post by:
Hello; A friend gave me this syntax and they are unavailable at the moment and I need this asap. I am trying to figure out how SQL figures this out. Below the syntax takes a field in a file and...
6
by: Brian | last post by:
what is the equivlant of the vb 6 instr I have a string there has "*D*N" I want to find the position that the D is in with a dotnet (VB) function
3
by: Alex Pavluck | last post by:
I have a date stored like this '2004 - 2006' and I use this code to get startyear and stopyear StartYear: Trim(Left(,InStr(,"-")-1)) StopYear: Trim(Right(,InStr(,"-")-1)) Is there a way to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.