0

In VFP9 there is an object reference THIS which provides a reference to the current object in event code or in a class definition. In vb.net there is ME but as i observed it referred to the actual form not the object itself.

VFP Code for button1 click:

this.caption = "CLICKED" <<OR>> thisform.button1.caption = "CLICKED"

VB Code

-----------------------  <<OR>> Me.button1.text="CLICKED"

I want to know the dotted line equivalent in vb.net, a reference to the current object. We have an VFP9 system and I'm trying to convert it to vb.net.

Ikong
  • 2,540
  • 4
  • 38
  • 58

1 Answers1

0

VFP works based on nested object references for the controls and "this" allows the capability of relative reference. If you wanted to long-hand the VFP equivalent, it would be something like

Thisform.button1.Caption = "CLICKED"

Now, that said, you may encounter other controls downstream in your conversion that look something like...

this.Parent.otherControl.something...

The ".Parent" just refers to the parent control of the current object. So, say you have a form with a pageframe... On that are 3 pages. On Page 1 has a container. That container has a textbox and a button.

In the click of the button, you want to display a message of the value in the textbox control. The button may have something like

Messagebox( This.Parent.TheTextBoxControl.Text )

You don't have to know how deep the container is buried in the form, you just know that the textbox is relative to the button via the same parent control.

DRapp
  • 47,638
  • 12
  • 72
  • 142
  • even if the button is inside a pageframe or a container inside a pageframe i don't have to do this `Messagebox( This.Parent.TheTextBoxControl.Text )` but only need to do it in this manner `Messagebox(this.caption)` in the clicke event of the button. Thats why `this` in vfp is not only for relative but also for the current object. I need to know if vb.net has the same method or ways. – Ikong Mar 12 '13 at 01:42
  • I do believe you can also reference similarly to VFP as in VB. Me.Parent.OtherControl as controls need to be associated with some other control for presentation in the form, and "parent" is a common property. You SHOULD be able to reference similarly. – DRapp Mar 12 '13 at 11:42