Solved

Instr in vb.net

Posted on 2009-05-05
4
396 Views
Last Modified: 2012-05-06
I have a line :

I went to town
For shopping
This is one line
which is debugged as   "I went to town For shopping"

I want to find in line 'For ' word..How do I achieve this
0
Comment
Question by:RIAS
  • 2
4 Comments
 
LVL 8

Assisted Solution

by:Haris V
Haris V earned 100 total points
ID: 24302985
0
 
LVL 6

Expert Comment

by:openshac
ID: 24303030
I am assuming that it is just a line break being used in the original string

        Dim myString As String
        myString = "I went to town\nFor shopping\nThis is one line"
 
        Dim start As Integer
        Dim firstLine As String
 
        start = InStr(myString, "\n")
        If (start > 0) Then
            firstLine = Mid(myString, start + 1)
        End If

Open in new window

0
 

Author Comment

by:RIAS
ID: 24303141
Hi,
How to find a word after a particular index?
0
 
LVL 6

Accepted Solution

by:
openshac earned 150 total points
ID: 24303194
Sorry I though you were looking for the word after the line break, if you are looking for a specific word then try this:

        Dim myString As String
        myString = "I went to town\nFor shopping\nThis is one line"
 
        Dim start As Integer
        Dim firstLine As String
        Dim myWord As String
 
        myWord = "For"
        start = InStr(myString, myWord)
        If (start > 0) Then
            firstLine = Mid(myString, start + 1)
        End If

Open in new window

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now