Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

albates1972

Automotive
Feb 10, 2010
44
0
0
US
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
 
Replies continue below

Recommended for you

Code:
dim strInput as string
dim pos as integer
strInput = "12345678-E1234567E00_1.pdf"
[COLOR=green]'look for position of hyphen[/color]
pos = InStr(strInput, "-")
[COLOR=green]'if hyphen is found, trim off all characters before hyphen (+1 to trim hyphen as well)[/color]
if pos > 0 then
strInput = Mid(strInput, pos + 1)
end if
 
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
 
Status
Not open for further replies.
Back
Top