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. error on using arrray...(not a member of the form) ??

error on using arrray...(not a member of the form) ??

Scheduled Pinned Locked Moved Visual Basic
csharpvisual-studiocomgame-devdata-structures
6 Posts 5 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
    campbells
    wrote on last edited by
    #1

    i was trying to make change on the text from the other form by using the array in a loop but the error about which it's not a member of the form1??? y?? i check properly the label was there and with correct name.... C:\Documents and Settings\acer\My Documents\Visual Studio Projects\SnL1\SnL1\PlayerSelect.vb(492): 'com' is not a member of 'SnL1.Form1'. here my coding: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim com As Label() = ControlArrayUtils.getControlArray(Me, "com") Dim x As Integer Dim game as new form1 Game.NumPlayer.Text = ComboBox1.Text Game.PTurn1.Text = TextBox1.Text Game.PTurn2.Text = TextBox2.Text Game.PTurn3.Text = TextBox3.Text Game.PTurn4.Text = TextBox4.Text For x = 1 To Val(ComboBox1.Text) Game.com(x).Text = y Next Game.Show() Me.Hide() End Sub

    G D C 3 Replies Last reply
    0
    • C campbells

      i was trying to make change on the text from the other form by using the array in a loop but the error about which it's not a member of the form1??? y?? i check properly the label was there and with correct name.... C:\Documents and Settings\acer\My Documents\Visual Studio Projects\SnL1\SnL1\PlayerSelect.vb(492): 'com' is not a member of 'SnL1.Form1'. here my coding: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim com As Label() = ControlArrayUtils.getControlArray(Me, "com") Dim x As Integer Dim game as new form1 Game.NumPlayer.Text = ComboBox1.Text Game.PTurn1.Text = TextBox1.Text Game.PTurn2.Text = TextBox2.Text Game.PTurn3.Text = TextBox3.Text Game.PTurn4.Text = TextBox4.Text For x = 1 To Val(ComboBox1.Text) Game.com(x).Text = y Next Game.Show() Me.Hide() End Sub

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      "com" is a variable in your code, not a member of the form. --- b { font-weight: normal; }

      C 1 Reply Last reply
      0
      • G Guffa

        "com" is a variable in your code, not a member of the form. --- b { font-weight: normal; }

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

        actually i found a lot of tis similar problem even i change the name it still hapen especially when refer to other form and not itself...

        H 1 Reply Last reply
        0
        • C campbells

          actually i found a lot of tis similar problem even i change the name it still hapen especially when refer to other form and not itself...

          H Offline
          H Offline
          HL_SUB
          wrote on last edited by
          #4

          'com' is a local variable in your event handler method. When you define a local variable in a function/method this variable is not in the group of from's/class's member variables so if you wish to use it just call it with it's name. HL

          1 Reply Last reply
          0
          • C campbells

            i was trying to make change on the text from the other form by using the array in a loop but the error about which it's not a member of the form1??? y?? i check properly the label was there and with correct name.... C:\Documents and Settings\acer\My Documents\Visual Studio Projects\SnL1\SnL1\PlayerSelect.vb(492): 'com' is not a member of 'SnL1.Form1'. here my coding: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim com As Label() = ControlArrayUtils.getControlArray(Me, "com") Dim x As Integer Dim game as new form1 Game.NumPlayer.Text = ComboBox1.Text Game.PTurn1.Text = TextBox1.Text Game.PTurn2.Text = TextBox2.Text Game.PTurn3.Text = TextBox3.Text Game.PTurn4.Text = TextBox4.Text For x = 1 To Val(ComboBox1.Text) Game.com(x).Text = y Next Game.Show() Me.Hide() End Sub

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            rompnet wrote:

            i was trying to make change on the text from the other form

            You should NOT be doing this. In proper OOP and UI design, one form should not be making any modifications to the controls of another. You should be exposing the data on your second form as Public Properties, so any other form that creates this form can retrieve any data it needs and can update it's own controls with that data. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            1 Reply Last reply
            0
            • C campbells

              i was trying to make change on the text from the other form by using the array in a loop but the error about which it's not a member of the form1??? y?? i check properly the label was there and with correct name.... C:\Documents and Settings\acer\My Documents\Visual Studio Projects\SnL1\SnL1\PlayerSelect.vb(492): 'com' is not a member of 'SnL1.Form1'. here my coding: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim com As Label() = ControlArrayUtils.getControlArray(Me, "com") Dim x As Integer Dim game as new form1 Game.NumPlayer.Text = ComboBox1.Text Game.PTurn1.Text = TextBox1.Text Game.PTurn2.Text = TextBox2.Text Game.PTurn3.Text = TextBox3.Text Game.PTurn4.Text = TextBox4.Text For x = 1 To Val(ComboBox1.Text) Game.com(x).Text = y Next Game.Show() Me.Hide() End Sub

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

              To add to Dave's reply: You might like to look at this article which shows you how to do what you want: Passing Values Between Forms[^] ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?

              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