Is This Content Helpful?
We're glad to know this article was helpful.
While Visual Basic and ArcView are communicating through DDE, and because they are running independently, you can change the state of ArcView. If you send an Avenue request to ArcView from Visual Basic to, for example, get the active view, there's no guarantee the active theme will be the view you want, even though it was when the Visual Basic application started.
You must program your Visual Basic application to handle this situation.
One approach is to evaluate, in the VB application, the string returned from ArcView. This string would tell you what the active document is. For example, if the string is NIL, which would happen if you sent a request to a view but a view is not the active document, you could terminate your application and display a message indicating that the operation could not be performed because the state of ArcView changed.
Another approach is to pass the name of the active document, and whatever other state information your application requires, to Visual Basic and store it in a hidden control on the form. Then, as part of the request you send to ArcView, you could restore ArcView's environment to the appropriate state. For example, if your application requires an active view and an active theme within that view, you could poke data from ArcView to Visual Basic:
'-- Connect to a Visual Basic application as a destination
aDDE = DDEClient.Make ("SomeApp","SomeTopic")
'-- Poke information into a hidden text field on the VB side
theView = av.GetActiveDoc
theTheme = theView.GetActiveThemes.Get(0)
'-- txtHidden is the name of the text box control in Visual Basic
Change the text strings SomeApp, SomeTopic, and txtHidden to items in your application.