returning values FROM window form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Graham  Blandford

    #1

    returning values FROM window form

    Hi all,

    Quickie - I hope. I already know how to use a forms New() Sub to receive
    parameters from a calling class - but I don;t know how to return values...

    Anyone know the recommended method for doing this?

    Thanks,
    Graham


  • William Ryan  eMVP

    #2
    Re: returning values FROM window form

    Create some properties corresponding to each of those values, or create a
    class that holds all of them and make a property of that class in your
    target form.

    Before that form closes, set them all...

    this.FirstValue YouWantReturned = Whatever;
    or me.FirstValueYo uWantReturned = Whatever (vb.net)
    and repeat this for each varaible. Assume these properties were added to
    Form2.

    So...

    Form2 frm = new Form2(SomeValue , SomeOtherValue) ;//this means you passed in
    two variables
    frm.Show();

    or Dim frm as Form2 = new Form2(SomeValue , SomeOtherValue)
    frm.Show()

    now, in form2 set those properties as I showed you above to the values you
    want returned

    string FirstValue = frm.FirstValueY ouWantReturned;
    string SecondValue = frm.SecondValue YouWantReturned ;

    same process for VB.NET at this point.

    Or you coudl just create one property of type someClass that contains all of
    the variables. Then you set them in the class (remember, it's still a
    property of Form2 which is essential to either approach, this just
    consolidates it).

    then

    string FirstValue = frm.SomeObject. FirstValueYouSe t;
    string SecondValue = frm.SomeObject. SecondValueYouS et;

    HTH,

    Bill

    --
    W.G. Ryan MVP Windows - Embedded




    "Graham Blandford" <graham.blandfo rd@sympatico.ca > wrote in message
    news:aFxtc.5412 7$tb4.1902615@n ews20.bellgloba l.com...[color=blue]
    > Hi all,
    >
    > Quickie - I hope. I already know how to use a forms New() Sub to receive
    > parameters from a calling class - but I don;t know how to return values...
    >
    > Anyone know the recommended method for doing this?
    >
    > Thanks,
    > Graham
    >
    >[/color]


    Comment

    • Graham  Blandford

      #3
      Re: returning values FROM window form

      Thanks Bill.

      I'll give it a try.


      "William Ryan eMVP" <dotnetguru@com cast.nospam.net > wrote in message
      news:OLN3eJHREH A.1388@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Create some properties corresponding to each of those values, or create a
      > class that holds all of them and make a property of that class in your
      > target form.
      >
      > Before that form closes, set them all...
      >
      > this.FirstValue YouWantReturned = Whatever;
      > or me.FirstValueYo uWantReturned = Whatever (vb.net)
      > and repeat this for each varaible. Assume these properties were added to
      > Form2.
      >
      > So...
      >
      > Form2 frm = new Form2(SomeValue , SomeOtherValue) ;//this means you passed[/color]
      in[color=blue]
      > two variables
      > frm.Show();
      >
      > or Dim frm as Form2 = new Form2(SomeValue , SomeOtherValue)
      > frm.Show()
      >
      > now, in form2 set those properties as I showed you above to the values you
      > want returned
      >
      > string FirstValue = frm.FirstValueY ouWantReturned;
      > string SecondValue = frm.SecondValue YouWantReturned ;
      >
      > same process for VB.NET at this point.
      >
      > Or you coudl just create one property of type someClass that contains all[/color]
      of[color=blue]
      > the variables. Then you set them in the class (remember, it's still a
      > property of Form2 which is essential to either approach, this just
      > consolidates it).
      >
      > then
      >
      > string FirstValue = frm.SomeObject. FirstValueYouSe t;
      > string SecondValue = frm.SomeObject. SecondValueYouS et;
      >
      > HTH,
      >
      > Bill
      >
      > --
      > W.G. Ryan MVP Windows - Embedded
      >
      > http://forums.devbuzz.com
      > http://www.knowdotnet.com/dataaccess.html
      > http://www.msmvps.com/williamryan/
      > "Graham Blandford" <graham.blandfo rd@sympatico.ca > wrote in message
      > news:aFxtc.5412 7$tb4.1902615@n ews20.bellgloba l.com...[color=green]
      > > Hi all,
      > >
      > > Quickie - I hope. I already know how to use a forms New() Sub to receive
      > > parameters from a calling class - but I don;t know how to return[/color][/color]
      values...[color=blue][color=green]
      > >
      > > Anyone know the recommended method for doing this?
      > >
      > > Thanks,
      > > Graham
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...