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?

Recommended Answers

All 4 Replies

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?

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?

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.