Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Instr in vb.net

Posted on 2009-05-05
4
Medium Priority
?
403 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Assisted Solution

by:Haris V
Haris V earned 400 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 600 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

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Simple Linear Regression

721 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