English

How To: Poke data into an ArcView script from Visual Basic

Summary

Poking data into ArcView from Visual Basic (ArcView as a source) is an easy way to execute a script and pass the value of the Visual Basic control as the SELF object to the script.

Procedure

For example, if you want to pass a comma-delimited list from Visual Basic to ArcView, use the following code in Visual Basic. This example shows how you can use a Visual Basic form to set some parameters and pass those parameters as arguments to an Avenue script.

  1. Create a form in Visual Basic with a CommandButton and a TextBox.
  2. Change the name of the TextBox to txtData.
  3. Add the following code to the click event of the CommandButton:

    Code:
    txtData.LinkMode = 0
    txtData.LinkTopic = "ArcView|System"
    txtData.LinkMode = 2
    txtData.LinkTimeout = 600
    txtData.Text = "item1,item2,item3"
    txtData.LinkItem = "String Script1"
    txtData.LinkPoke
    txtData.LinkMode = 0

    The components of txtData.LinkItem are a keyword "string" that indicates the data type followed by the name of the script to run, in this case, Script1.
  4. Open ArcView and a new Script window.
  5. Copy and paste the following code into the Script window:

    Code:
    theItems = Self.AsTokens(",")
    MsgBox.ListAsString(theItems, "Poke Test", "Test")

  6. Click the Compile button.
    [O-Image] Script compile button

  7. Run the Visual Basic form.