Solved

remove first 3 lines of a string

Posted on 2013-11-07
10
228 Views
Last Modified: 2013-11-07
I have a textbox listed below and would like to know how to remove the first couple of line.  I would like my textbox to start with the line "insert_job"


 
 /ASYS /backup /bin /boot /CC /dev /etc /export /home /lib /lib64 /lost+found /media /misc /mnt /net /opt /oracle /proc /PSL_install.log /root /sbin /selinux /srv /sys /tmp /usr /var ----------------- chadster ----------------- */
 
 insert_job: chadster job_type: c
 command: sleep 2
 machine: server2
 owner: userid
 permission: gx
 description: "clone test job"
 std_out_file: /tmp/chadster.out
 std_err_file: /tmp/chadster.err
 alarm_if_fail: 0
0
Comment
Question by:chadmanvb
[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
  • 6
  • 3
10 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630239
is it always that sequence character for character before
Insert Job ?
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630245
also is the output of the textbox a string ?
0
 

Author Comment

by:chadmanvb
ID: 39630261
No, the text before "insert" does change everytime and I am useing a string for the textbox.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:plusone3055
ID: 39630325
okay then there are 2 steps to this

1. you need to do an indexof the string that is the textbox looking for
insert_job:

intposition = strtextbox.Indexof("insert_Job",0)

2. use RIGHt to display everything to the RIGHT of that inpostion from the string

dim strtexboxoutput as string = RIGHT(strtextbox,inposition)


that should do the trick
0
 

Author Comment

by:chadmanvb
ID: 39630507
What am I doing wrong?  It have -1 for my intposition and that does not seem correct.  Also I cant compile with inposition on the last line.

Here is what I have

 Dim intposition
        Dim strtextbox As String = TextBox1.Text

        intposition = strtextbox.IndexOf("insert_Job", 0)
        MsgBox(intposition)

        Dim strtexboxoutput As String = Strings.Right(strtextbox, inposition)
0
 
LVL 22

Accepted Solution

by:
plusone3055 earned 500 total points
ID: 39630575
this works

       Dim str123 As String
        str123 = txt1.Text
        MessageBox.Show(str123)

        Dim intposition As Integer
        intposition = str123.IndexOf("insert", 0)
        MessageBox.Show(intposition)

        Dim stroutput As String = str123.Substring(intposition)

        MessageBox.Show(stroutput)
0
 

Author Closing Comment

by:chadmanvb
ID: 39630602
Pefect!  Thanks!
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630614
no problem happy coding :)
0
 
LVL 40
ID: 39630619
Take the time to define the type of your variables. It prevents many types of bugs:

Dim intposition as Integer.

IndexOf is sensitive to case. According to your original question, you should look for insert_job with a lowercase 'j'.

The last line does not work because you forgot the 't' in the third character of intposition.
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630633
JamesBurger is right
I didnt even see the syntax errors on that when you posted until he pointed them out. Slow and steady does win the race :)
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 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