Results 1 to 6 of 6

Thread: passing data form form1 to form2 (or vice versa)

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    canada, eh
    Posts
    2

    Question passing data form form1 to form2 (or vice versa)

    how can you change a value in another form from another form?
    in vb6 you could just do this:

    form1.label.caption = "blah"


    what ive done is this:

    dim frm as new form1
    form1.label.caption = "halb"

    but this will only work if i hide form1, then show it again after im done with form2.
    any help is appreciated
    "Well of course, everything looks bad if you remember it." - Homer Simpson

  2. #2
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    make a property on form one

    VB Code:
    1. Public Property LabelCaption() As String
    2.         Get
    3.              LabelCaption=Label.Text
    4.         End Get
    5.         Set(ByVal Value As String)
    6.             Label.Text = LabelCaption
    7.         End Set
    8.     End Property

    that should work. then Form1.LabelCaption = "New Data"

    and if you make a new form1 you are working with a new form1
    not the one you where looking at

    try activeForm
    Magiaus

    If I helped give me some points.

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2002
    Location
    canada, eh
    Posts
    2
    well i made the public property on form1, but how do i use it on form2????

    just typing form1.label = "whatever" wont work, i would have to dim frm as new form1 then do frm.label = "whatever" but then its the same problem as before.

    what do you mean by try activeform?
    "Well of course, everything looks bad if you remember it." - Homer Simpson

  4. #4
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    you don't need the property i posted that before i realized what i was saying. look here for some help http://www.vbforums.com/showthread.p...42#post1151542

    and maybe cander can explain it to you i am at a loss to provide a good explination.
    Magiaus

    If I helped give me some points.

  5. #5
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    oh and if you made the property shared it would work but on all form1's
    Magiaus

    If I helped give me some points.

  6. #6
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    ok go look at the other thread

    http://www.vbforums.com/showthread.p...hreadid=195395

    i posted a form mamnger class in it
    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width