Author Topic: passing variables between forms  (Read 1017 times)

ddddd13

  • Full Member
  • ***
  • Posts: 118
    • View Profile
passing variables between forms
« 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   

Godra

  • Hero Member
  • *****
  • Posts: 1447
    • View Profile
Re: passing variables between forms
« Reply #1 on: June 03, 2019, 02:34:58 PM »
TextBox1.Text = MainForm.aerotest