DanFHiggins Posted December 6, 2011 Posted December 6, 2011 (edited) I am building layer states in Civil 3d 2011 to show all discipline types either within dwg or in xref in VBA. Discipline types will be selected by user ex. V-, C-, D-. I can get the ones local by looking at the first two characters in the layer name ex. V-Road-Edge, C-ALIN-CNTR. The issue comes with searching for the | character in the xref layer name. ex DGWNAME|V-NODE-UTIL, Thomson|C-TINN. Using the INSTR command does not see the character in the xref name. I need to find where in the string it resides. I am using chr(124) to match. Any ideas would be appreciated. Thanks Edited December 6, 2011 by DanFHiggins clarification of programming platform Quote
BlackBox Posted December 6, 2011 Posted December 6, 2011 Welcome to CADTutor! First, I'd caution you that VBA is on its way out, so you may want to consider jumping to VB.NET if you are adept at coding in VBA (especially for interacting with Civil 3D's Aecc* Objects!). If not adept at coding in VBA, then consider Visual LISP as another option. As to your question, consider using the Contains, or InStr Methods, just be sure to test / set the string case using the ToUpper, or ToLower Methods accordingly. Untested examples: Option Explicit Public Sub FOO() Dim myString as string = "Hello World!" Dim keyWord as string = "hello" If myString.ToUpper.Contains(keyWord.ToUpper) Then ' <-- Do somthing Else ' <-- Do something else End if End Sub ** Note - I know the Contains Method works in .NET, I am unsure if this is the case for VBA in AutoCAD; you may need to use InStr Method. Please let me know which one works for you. Hope this helps (HTH)! Quote
DanFHiggins Posted December 7, 2011 Author Posted December 7, 2011 This works giving you the position of the pipe ( | ) character in the string. n = InStr(1, la.Name, "|", vbTextCompare) Quote
BlackBox Posted December 7, 2011 Posted December 7, 2011 I'm glad to hear that. Out of curiosity, and frankly for my own edification; does the Contains Method work in VBA as it does in VB.NET? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.