I'm writing VBA in Microstation and I want to populate a text field PathToScan
with the active design file's path, which is ActiveDesignFile.Path
.
What I'm currently attempting has worked just moments ago but for some reason isn't working now.
This is the code I'm using to populate the text field.
Private Sub UserForm_Initialize()
Debug.Assert TypeOf Me.PathToScan Is TextBox
Debug.Assert TypeName(ActiveDesignFile.Path) = "String"
Debug.Assert ActiveDesignFile.Path <> ""
Me.PathToScan.Text = ActiveDesignFile.Path
Debug.Assert Me.PathToScan.Text = ""
Do Until Me.PathToScan.Text = ActiveDesignFile.Path
Debug.Print Me.PathToScan.Text, ActiveDesignFile.Path
Me.PathToScan.Text = ActiveDesignFile.Path
Debug.Assert Me.PathToScan.Text = ActiveDesignFile.Path 'this is where it catches
Loop
End Sub
I can also make the change myself to the value of the TextBox, and Debug.Print Me.PathToScan.Text
correctly returns the value that I entered manually.
And now I'm seeing that the definition Me.PathToScan.Text = ActiveDesignFile.Path
always defines Me.PathToScan.Text
as the empty string.
What could be causing this?
The issue is that the handler for a change to PathToScan was resetting the value to "" due to a failure in another calling function:
Private Sub PathToScan_Change()
Me.PathToScan = TrimDoubleQuotes(Me.PathToScan) 'this was returning blank by accident
End Sub
This change clears it up.