1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

VB-2010 accessing a public string variable

Discussion in 'Programming' started by JCT, Jul 11, 2011.

  1. JCT

    JCT New Member

    Jul 11, 2011
    Likes Received:
    Trophy Points:
    Upfront, I am quite new to Visual Basic.

    My question: How can I "pass" or reference a simple string variable across 2 forms.

    I start my main form with:
    Public Class Interface
    Public Namevar As String

    Now then, I want to fire up a subform, SubSearch with a button click. So:

    Private Sub SearchRun_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SearchRun.Click
    End Sub

    So far so good.
    However, I want to use Namevar within SubSearch. Since I initially declared Namevar as Public, I thought it's value would be available in my Subform. But everything I have tried has failed.

    Any help will be appreciated.



Share This Page