Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

characters before the "-" symbol 1

Status
Not open for further replies.

accessvbahelp

Technical User
Oct 26, 2011
24
US
How do I write code to figure out how to recognize the characters before the "-" symbol. If my part is 301-001 I need to capture the 301 if the part is BBLNK-001 I need to capture BBLNK. This is what I have but it only works for the first three characters.

Code:
Dim strDwgNumb As String
Dim strRev As String
Dim strFolder As String

DwgNumb = Forms("frmMain")!DrawingNumber.Value 'Gets drawing number from form
Rev = Forms("frmMain")!Revision.Value 'Gets revision letter from form
Folder = Left(DrawingNumber, "3") 'Pulls folder number from first three characters of drawing number

Thank you all for your help! I am new at writing code, Thank you for being patient.
 
Have a look at the InStr function.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Dim strDwgNumb As String
Dim strRev As String
Dim strFolder As String
Dim varItem As Variant

strDwgNumb = Forms("frmMain")!DrawingNumber.Value 'Gets drawing number from form
strRev = Forms("frmMain")!Revision.Value 'Gets revision letter from form
varItem = Split(DrawingNumber, "-")
strFolder = varItem(0) ' The other pc of DrawingNumber can be referenced like varItem(1) if needed

untested thoughts?







HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
THANK YOU MazeWorX!!!

I was able to capture the characters before the "-'!!!
 
cool

HTH << MaZeWorX >> "I have not failed I have only found ten thousand ways that don't work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top