V8i 359 - VB - Help needed in redirecting a variable path

I’m trying to redefine a line in an existing custom vb programme and I have only just started to understand vb.net but have written in vba previously (some years ago).

This is the line I want to edit:

StartProjectNumber = MSApp.ActiveWorkspace.ExpandConfigurationVariable("$(first(_USTN_PROJECTNAME))")

 

The history… I’m trying to tidy up a messy workspace and part of that is the project list, we have four and five digit project numbers but due to the numeric nature of the list our 10000 numbers appear at the head of the list when they should follow behind 9999. This is easy enough to fix which I did by adding a preceding ‘0’ to the four digit numbers to make them all five digits but I didn’t anticipate the effect on some custom programming, which verifies the correct project is open against the open file.

 

The result is the programme now fails because it interprets 09999 from the pcf as not matching the directory which is actually 9999.

 

So I need to find a way of either redefining "StartProjectNumber" so that the expanded variable $(_USTN_PROJECTNAME) loses the preceding zero or look at replacing it with a shortened path from $(_DGNDIR) i.e. $(_DGNDIR)=S:\9999\ to drop the ‘S:\’ and end ‘\’  to get ‘9999’

Any suggestions will be gratefully received.

Thanks.

Parents
  • Unknown said:
    Any suggestions will be gratefully received

    I used LINQPad to write some code to analyse your path using VB.NET methods and Regular Expressions...

    Here's the code...

    Debug.WriteLine("Parsing folder path using VB.NET methods")
     
    Dim path as String
    path="S:\9999\"
    Debug.WriteLine ("Path=" & path)

    Dim drive as String = Microsoft.VisualBasic.left(path,3)
    Debug.WriteLine ("Drive=" & drive)

    Dim last As String=Microsoft.VisualBasic.Right(path,1)
    Debug.WriteLine ("Last=" & Last)

    Dim folder As String=Microsoft.VisualBasic.Mid(path, 4, Microsoft.VisualBasic.Len(path)-4)

    Debug.WriteLine ("Folder=" & folder)

    Debug.WriteLine ("Parsing folder path using Regular Expressions")

    Dim regex As System.Text.RegularExpressions.Regex = _
        New System.Text.RegularExpressions.Regex("\d+")
    Dim match As System.Text.RegularExpressions.Match = regex.Match(path)
    If match.Success Then
        Debug.WriteLine("Folder=" & match.Value)
    End If

     
    Regards, Jon Summers
    LA Solutions

Reply
  • Unknown said:
    Any suggestions will be gratefully received

    I used LINQPad to write some code to analyse your path using VB.NET methods and Regular Expressions...

    Here's the code...

    Debug.WriteLine("Parsing folder path using VB.NET methods")
     
    Dim path as String
    path="S:\9999\"
    Debug.WriteLine ("Path=" & path)

    Dim drive as String = Microsoft.VisualBasic.left(path,3)
    Debug.WriteLine ("Drive=" & drive)

    Dim last As String=Microsoft.VisualBasic.Right(path,1)
    Debug.WriteLine ("Last=" & Last)

    Dim folder As String=Microsoft.VisualBasic.Mid(path, 4, Microsoft.VisualBasic.Len(path)-4)

    Debug.WriteLine ("Folder=" & folder)

    Debug.WriteLine ("Parsing folder path using Regular Expressions")

    Dim regex As System.Text.RegularExpressions.Regex = _
        New System.Text.RegularExpressions.Regex("\d+")
    Dim match As System.Text.RegularExpressions.Match = regex.Match(path)
    If match.Success Then
        Debug.WriteLine("Folder=" & match.Value)
    End If

     
    Regards, Jon Summers
    LA Solutions

Children