×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB Code help (code line to remove text before "-")

VB Code help (code line to remove text before "-")

VB Code help (code line to remove text before "-")

(OP)
I was needing a command line to remove the beginning part of an output file currently being produced by our VB program.  I am using a program that creates a PDF into a certain file structure.  With recent filenaming sructure changes, I need to remove part of the output file.  (see example below)

Output file: ABC12345-E1234567E00_1.pdf
or :         12345678-E1234567E00_1.pdf

I was needing to remove the first part of the file before the "-".

I need a new output to be: E1234567E00_1.pdf

It will need to be a IF THEN statement also.  There is another file structure that already gets me to the correct file format.

Thank you,

Allen

Current version: NX 5.0.4.1

RE: VB Code help (code line to remove text before "-")

CODE

dim strInput as string
dim pos as integer
strInput = "12345678-E1234567E00_1.pdf"
'look for position of hyphen
pos = InStr(strInput, "-")
'if hyphen is found, trim off all characters before hyphen (+1 to trim hyphen as well)
if pos > 0 then
strInput = Mid(strInput, pos + 1)
end if

RE: VB Code help (code line to remove text before "-")

(OP)
Cowski,

I had to modify it a bit to incorporate my existing "StrInput" file.  I was able to use the main portion and make it work for us.

Thanks a lot,

Allen

Current version: NX 5.0.4.1

RE: VB Code help (code line to remove text before "-")

Excellent.

Glad I could help.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources