Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: Using a MACRO to change specific reference file logical names

$
0
0

Hi Taylor,

in my opinion Chuck's code is not robust enough, because it works for 4 characters after the digits only, which has not been defined it will be always true.

You can adapt this example to have flexible and robust code. The first function remove all leading numbers, the second one converts all characaters in string to uppercase.

Private Function StripLeadingNumbers(inputText As String) As String
    Dim textLength As Long
    textLength = Len(inputText)

    Dim position As Long
    For position = 1 To textLength
        If Not IsNumeric(Mid(inputText, position, 1)) Then
            Exit For
        End If
    Next

    StripLeadingNumbers = Mid(inputText, position, textLength - position + 1)
End Function

Private Function ConvertToUpperCase(inputText As String) As String
    ConvertToUpperCase = UCase(inputText)
End Function

Public Sub ExampleStripAndConvert()
    Dim text As String
    text = "314159268MyReferenceFile"

    Dim outputText As String
    outputText = StripLeadingNumbers(text)
    outputText = ConvertToUpperCase(outputText)

    MsgBox "Striped and uppercased: " & outputText
End Sub

With regards,

 Jan


Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>