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. Quick question about classes in VB.NET

Quick question about classes in VB.NET

Scheduled Pinned Locked Moved Visual Basic
questioncsharphelptutorial
3 Posts 2 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.
  • C Offline
    C Offline
    CodeChicken
    wrote on last edited by
    #1

    Does anybody know how to bounce data between two unrelated classes? I know you can call subroutines in the derived class from the base class, but im not sure how to go the other way. To be more specific, I'm trying to change a property on a control in one form from another. Please help :confused: Scientist have pondered for thousands of years, "What came first? The CodeChicken or the egg?".

    C 1 Reply Last reply
    0
    • C CodeChicken

      Does anybody know how to bounce data between two unrelated classes? I know you can call subroutines in the derived class from the base class, but im not sure how to go the other way. To be more specific, I'm trying to change a property on a control in one form from another. Please help :confused: Scientist have pondered for thousands of years, "What came first? The CodeChicken or the egg?".

      C Offline
      C Offline
      CodeChicken
      wrote on last edited by
      #2

      Just thought I'd let everybody know that I figured this out and this is how I did it. For instance, if form1 spawns a new class called class1, you dimension a reference to the form inside the class with this code: public formlink as form1 = form1.activeform After you've done this, you can call anything from form1 using formlink. For instance to add to a listbox on form1 from class1 you would use this code: formlink.listbox1.items.add("hello world") I hope this helps anyone else that is trying to pass data between forms. I know it was easier in vb6, but now that forms are classes, it makes it much more confusing. Thanx for reading :-D Scientist have pondered for thousands of years, "What came first? The CodeChicken or the egg?".

      C 1 Reply Last reply
      0
      • C CodeChicken

        Just thought I'd let everybody know that I figured this out and this is how I did it. For instance, if form1 spawns a new class called class1, you dimension a reference to the form inside the class with this code: public formlink as form1 = form1.activeform After you've done this, you can call anything from form1 using formlink. For instance to add to a listbox on form1 from class1 you would use this code: formlink.listbox1.items.add("hello world") I hope this helps anyone else that is trying to pass data between forms. I know it was easier in vb6, but now that forms are classes, it makes it much more confusing. Thanx for reading :-D Scientist have pondered for thousands of years, "What came first? The CodeChicken or the egg?".

        C Offline
        C Offline
        Csharp
        wrote on last edited by
        #3

        if you want to pass data between forms , you can add owned forms, eg: in Form1: Dim frm As New Form2 Me.AddOwnedForm(frm) frm.Show() in Form2: Dim frmMain As Form1 = Me.Owner frmMain.TextBox1.Text = "something from Form2, passed to Form1!":)

        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