Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Passing variable values between forms

Passing variable values between forms

Scheduled Pinned Locked Moved Visual Basic
questionlounge
3 Posts 2 Posters 16 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    This may be a dumb question: I have the variable Port of type integer declared in a module like this: Dim Port as Integer (in general declarations) I then have it declared in each of my forms like this: Dim Port as Integer (in general declarations) How do I pass the value of Port in my main form (frmMain) to another form called from frmMain? David.

    J L 2 Replies Last reply
    0
    • L Lost User

      This may be a dumb question: I have the variable Port of type integer declared in a module like this: Dim Port as Integer (in general declarations) I then have it declared in each of my forms like this: Dim Port as Integer (in general declarations) How do I pass the value of Port in my main form (frmMain) to another form called from frmMain? David.

      J Offline
      J Offline
      Jason Gerard
      wrote on last edited by
      #2

      First of all, you have to change the declaration of Port from Private (Dim) to Public. Then you can just reference the variable using the form name. Ex: form1.Port = frmMain.Port. Hope this helps Jason Gerard MCSD, MCSE Technology Point International, Inc.

      1 Reply Last reply
      0
      • L Lost User

        This may be a dumb question: I have the variable Port of type integer declared in a module like this: Dim Port as Integer (in general declarations) I then have it declared in each of my forms like this: Dim Port as Integer (in general declarations) How do I pass the value of Port in my main form (frmMain) to another form called from frmMain? David.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        You dont even have to declare it on each form. Just reference the one in frmMain as illustrated by Jason. Make it local to the function you are using it in Private Sub cmdDoStuff_Click() Dim iPort as Integer iPort = frmMain.Port ' etc. End Sub

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups