VB-2010 accessing a public string variable

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

  1. JCT

    JCT New Member

    Joined:
    Jul 11, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
    SubSearch.Show()
    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.

    Jim

     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice