Solved

Transferring a variable to a form

Posted on 2010-11-15
2
221 Views
Last Modified: 2012-06-27
I have a variable that is declared at execution. I need to get that variable into my form so I can access it. The variable I need is commandData. I cannot declare it public because the value is set at execution. Is there a way to pass a variable to a form? the only thing I can find is from one form to another. Here is the code:

 Public Function Execute(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData, ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute
        Dim fm1 As New ContentBrowser()
        Dim components = New Container()
        Dim resources As New ResourceManager(GetType(ContentBrowser))
        Dim tabControl1 As New TabControl()
        Dim tabPage1 As New TabPage()
        Dim myImages As New ImageList(components)
        ' Construct the ImageList.
        Dim ImageList1 = New ImageList
        fm1.Show()
    End Function
0
Comment
Question by:mgsell
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 34141269
Sure you can...but your form needs a place to store it!

So you could either:
(1) Override the constructor so the value is received when you create a new instance of the form.
(2) Add a public member (or a private with a public property wrapper).

In either case, you need to add a variable of type Autodesk.Revit.UI.ExternalCommandData to the form:

    Public Class ContentBrowser

        Public CommandData As Autodesk.Revit.UI.ExternalCommandData

    End Class

Simple example of #2:

    Dim fm1 As New ContentBrowser()
    fm1.CommandData = commandData
    ...
0
 

Author Comment

by:mgsell
ID: 34146010
That worked perfectly!
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now