How do I use the right function and instr to capture all of the characters to the right of a known charachter.

Good morning experts!

I am trying to capture all of the characters to the right of the colon in a string, using the function below, and I am only getting part of the string. I will include all of the pertinent code.

<%# reqoptions(DataBinder.Eval(Container.DataItem, "requiredoption")& string.empty) %>

above returns from the database "Required_Options:Showerhead,Handshower" WITHOUT the function
returns from the database: "erhead,Handshower"  WITH the function      

I think i need to set the length? The length to the right of the colon will vary per record.      

  Protected Function reqoptions(ByVal requiredoption As String) As String
     If requiredoption <> "" Then
     return Right(requiredoption, InStr(requiredoption, ":"))
  else
  return nothing
      End If
 End Function
dplsrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mikal613Commented:
Protected Function reqoptions(ByVal requiredoption As String) As String
     If requiredoption <> "" Then
     return Right(requiredoption, InStrRev(requiredoption, ":"))
  else
0
Mikal613Commented:
try instrrev
0
dplsrAuthor Commented:
Hi Mikal613,

still returns

erhead,Handshower
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Mikal613Commented:
right(requiredoption,len(requiredoption) - instrrev(requiredoption,":"))
0
Mikal613Commented:
Protected Function reqoptions(ByVal requiredoption As String) As String
     If requiredoption <> "" Then
     return right(requiredoption,len(requiredoption) - instrrev(requiredoption,":"))
  else
  return nothing
      End If
 End Function
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
dplsrAuthor Commented:
Bingo!

thank you!
what is the diference between instr and instrrev (in a nutshell)?
0
willcode4coffeeCommented:
Try this:

Dim iStart As Integer

iStart = RequiredOption.IndexOf(":") + 1
Return RequiredOption.SubStr(iStart, RequiredOption.Length - iStart)

M@
0
Mikal613Commented:
one goes from the right and one goes from the left

basically

Instr goes from the Left

Instr REVERSE goes from the right
0
willcode4coffeeCommented:
The difference between InStr and InstrRev is that InstrRev starts at the END of the string and works backwards while InStr starts at the beginning of the string and works forward.
0
dplsrAuthor Commented:
ok!  have a good day
0
Mikal613Commented:
u 2

Want some cofee?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.