0

after searching on the web, i know that Me keyword is use to Refer to the Current Instance of an Object, but if i want to Refer to the others Instance of an Object, what is the keyword that i need to use?

3
Contributors
4
Replies
6
Views
5 Years
Discussion Span
Last Post by Reverend Jim
0

What do you mean by:

... but if i want to Refer to the others Instance of an Object?

Can you show a simple code example?

0
Dim dt As New DataTable
        'fill data to datatable
        da.Fill(dt)

        'offer data in data table into datagridview
        Me.DataGridView1.DataSource = dt
    Me keyword is use to Refer to the Current Instance of an Object,for example,the coding above will show the data in datagrid inside the current form. but what if i want to show the datagrid on another form inside the same project?

Edited by pyTony: use ~~~ vb fencing code tags

0

In your case, Me is not necessary, since you have this code on the same form as the datagridview control. You use Me in cases where is possible that comes to an ambiguity.
Like this example:

    Public Class Employee
        Private name As String
        Public Sub New(name As String)
                'this.name refers to private variable in the Employee class, while name refers to the method`s parameter
            Me.name = name
        End Sub
    End Class

Edited by pyTony: use ~~~ vb fencing code tags

0

Each object (control) that you create is given a unique name by default, such as TextBox1, TextBox2, etc. which you are free to change as long as it remains unique. You can see that name in the properties view. Just refer to the object by that name.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.