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 value from one form to another

passing value from one form to another

Scheduled Pinned Locked Moved Visual Basic
questioncsharpasp-netdatabase
5 Posts 4 Posters 0 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.
  • P Offline
    P Offline
    Pradip Kishore
    wrote on last edited by
    #1

    can we pass a value from one windows form to another windows form as we do in asp.net (using session or cookies)..???i m using vb.net... for ex i have a main form (form_main) in which i enter a id no in a textbox (tbid).when i press the submit button,another form(form_month) will be displayed which will ask for the monthly break up of the amount collected in the form_main. i want to enter the monthly break up amount along with the id (which is present in the form_main in tbid textbox).how can i insert that selected id value (from the form_main ) into the form_month when i will press the submit button of form_month (since form_month doesnt contain the field tbid..so i cant write the tbid.text value in the nsert query if form_month) i want to save the data of form_main and form_month in 2 different tables with a common attribute id in both table its urgent...any help in this regard will be highly appreciated..

    pradip kishore

    A C 2 Replies Last reply
    0
    • P Pradip Kishore

      can we pass a value from one windows form to another windows form as we do in asp.net (using session or cookies)..???i m using vb.net... for ex i have a main form (form_main) in which i enter a id no in a textbox (tbid).when i press the submit button,another form(form_month) will be displayed which will ask for the monthly break up of the amount collected in the form_main. i want to enter the monthly break up amount along with the id (which is present in the form_main in tbid textbox).how can i insert that selected id value (from the form_main ) into the form_month when i will press the submit button of form_month (since form_month doesnt contain the field tbid..so i cant write the tbid.text value in the nsert query if form_month) i want to save the data of form_main and form_month in 2 different tables with a common attribute id in both table its urgent...any help in this regard will be highly appreciated..

      pradip kishore

      A Offline
      A Offline
      Alex UEA
      wrote on last edited by
      #2

      form_month needs to know about form_main In form_month:- Public Class form_month Private m_FormMain As form_main Public Sub New(ByRef formMain As form_main) MyBase.New() m_FormMain = formMain 'setting a ref to the orig form form_main ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub In form_main:- Public Class form_main Dim m_form_month As New form_month(Me) in the code for the submit button to open form_month:- m_form_month.Show() in the code for the load event for form_month read the value of tbid:- Private Sub form_month_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim contentsOftbid As String contentsOftbid = m_FormMain.tbid.Text hope this helps Alex

      C P 2 Replies Last reply
      0
      • P Pradip Kishore

        can we pass a value from one windows form to another windows form as we do in asp.net (using session or cookies)..???i m using vb.net... for ex i have a main form (form_main) in which i enter a id no in a textbox (tbid).when i press the submit button,another form(form_month) will be displayed which will ask for the monthly break up of the amount collected in the form_main. i want to enter the monthly break up amount along with the id (which is present in the form_main in tbid textbox).how can i insert that selected id value (from the form_main ) into the form_month when i will press the submit button of form_month (since form_month doesnt contain the field tbid..so i cant write the tbid.text value in the nsert query if form_month) i want to save the data of form_main and form_month in 2 different tables with a common attribute id in both table its urgent...any help in this regard will be highly appreciated..

        pradip kishore

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        See: Passing Values between Forms[^]


        Upcoming events: * Glasgow Geek Dinner (5th March) * Glasgow: Tell us what you want to see in 2007 My: Website | Blog | Photos

        1 Reply Last reply
        0
        • A Alex UEA

          form_month needs to know about form_main In form_month:- Public Class form_month Private m_FormMain As form_main Public Sub New(ByRef formMain As form_main) MyBase.New() m_FormMain = formMain 'setting a ref to the orig form form_main ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub In form_main:- Public Class form_main Dim m_form_month As New form_month(Me) in the code for the submit button to open form_month:- m_form_month.Show() in the code for the load event for form_month read the value of tbid:- Private Sub form_month_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim contentsOftbid As String contentsOftbid = m_FormMain.tbid.Text hope this helps Alex

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          That would work, but the problem is you need to make your controls public. Instead, you should expose properties, or use delegates, to hide as much detail of your class as possible.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          1 Reply Last reply
          0
          • A Alex UEA

            form_month needs to know about form_main In form_month:- Public Class form_month Private m_FormMain As form_main Public Sub New(ByRef formMain As form_main) MyBase.New() m_FormMain = formMain 'setting a ref to the orig form form_main ' This call is required by the Windows Form Designer. InitializeComponent() ' Add any initialization after the InitializeComponent() call. End Sub In form_main:- Public Class form_main Dim m_form_month As New form_month(Me) in the code for the submit button to open form_month:- m_form_month.Show() in the code for the load event for form_month read the value of tbid:- Private Sub form_month_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim contentsOftbid As String contentsOftbid = m_FormMain.tbid.Text hope this helps Alex

            P Offline
            P Offline
            Pradip Kishore
            wrote on last edited by
            #5

            Hi Alex thanks a lot for your simple and quick response..

            pradip kishore

            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