Solved

remove first 3 lines of a string

Posted on 2013-11-07
10
223 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
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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