Solved

remove first 3 lines of a string

Posted on 2013-11-07
10
216 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
 
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

747 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

13 Experts available now in Live!

Get 1:1 Help Now