Solved

Instr in vb.net

Posted on 2009-05-05
4
394 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
Comment Utility
0
 
LVL 6

Expert Comment

by:openshac
Comment Utility
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
Comment Utility
Hi,
How to find a word after a particular index?
0
 
LVL 6

Accepted Solution

by:
openshac earned 150 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Retain selection in datagridview 2 22
Using MS Code on my Mac 6 44
Total in textboxes 9 34
c# if statement weird reaction 3 29
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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