AdvancedHMI Software

General Category => Support Questions => Topic started by: ddddd13 on June 03, 2019, 02:18:30 PM

Title: passing variables between forms
Post by: ddddd13 on June 03, 2019, 02:18:30 PM
I am new and I need help!
I am trying to pass a variable between forms. To make it simple. Imagine 2 forms, Main and form101.
On the main form I click on view code and add the following variable.
Public Class MainForm
    '*******************************************************************************
    Public aerotest As String = "works"

On form2 I have a text box with the following code.

Public Class Form101
    Private Sub Form101_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Text = aerotest
    End Sub

I expected the defining of the variable in the Main form would allow me to use it on Form101 but I get an alarm.

Error   BC30451   'aerotest' is not declared. It may be inaccessible due to its protection level.

Any help would be greatly appreciated.

Thanks,
Dave   
Title: Re: passing variables between forms
Post by: Godra on June 03, 2019, 02:34:58 PM
TextBox1.Text = MainForm.aerotest