Windows Develop Bookmark and Share   
 index > Windows Forms General > What is the VB equivalent command of "this" in C++
 

What is the VB equivalent command of "this" in C++

I have a C++ code that I need to change to VB

what d be the VB command like "This" in C++

And what does "This" do Excatly in C++

Thanks

R.Tutus  Friday, May 19, 2006 2:00 AM

wow

The odds of you being able to do this coversion are probably pretty low. C++ is a very different beast to VB. this returns a pointer to the current object. As such, it's pretty much always superfluous, but I think VB has Me as an alternative. However, if you had, for example this->CallMyFunc();, CallMyFunc() would work fine on it's own, so you can probably drop the 'this'.

How big is this chunk of code ? Can you post it ?

cgraus  Friday, May 19, 2006 2:40 AM

wow

The odds of you being able to do this coversion are probably pretty low. C++ is a very different beast to VB. this returns a pointer to the current object. As such, it's pretty much always superfluous, but I think VB has Me as an alternative. However, if you had, for example this->CallMyFunc();, CallMyFunc() would work fine on it's own, so you can probably drop the 'this'.

How big is this chunk of code ? Can you post it ?

cgraus  Friday, May 19, 2006 2:40 AM

Thanks for the compliment. The description of my real pb is in this post:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=410927&SiteID=1

My problem is that the execution doesn't execute Paint method (pls check that post).

As for the code I m trying to translate, here it s:

protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle bounds, System.Windows.Forms.CurrencyManager source, int rowNum, System.Drawing.Brush backBrush, System.Drawing.Brush foreBrush, bool alignToRight)

{

//clear the cell

g.FillRectangle(new SolidBrush(Color.White), bounds);

//compute & draw the value

//string s = string.Format("{0} row", rowNum);

// col 0 + 2 chars from col 1

DataGrid parent = this.DataGridTableStyle.DataGrid;

string s = parent[rowNum, 0].ToString() + ((parent[rowNum, 1].ToString())+ " ").Substring(0,2);

Font font = new Font("Arial", 8.25f);

g.DrawString(s, font, new SolidBrush(Color.Black), bounds.X, bounds.Y);

font.Dispose();

}

Thanks for your time.

R.Tutus  Friday, May 19, 2006 2:57 AM

OK - you said C++, this is C#.

Like I said, this is superfluous, you can just remove it, or replace it with Me.

cgraus  Friday, May 19, 2006 3:08 AM

Ok,I ll replace it with you (i mean with Me:) ). If u have a chance take a look at my other thread

Gracias amigo

R.Tutus  Friday, May 19, 2006 3:10 AM

You can use google to search for other answers

Custom Search

More Threads

• Hidden Forms?
• reading an array
• Windows forms C++ Samples
• Pressing multiple buttons at once
• Pass around object references or IDs?
• Change tab top border color
• How can I retain the filename in open file dialog and save it in the same name?
• Storing configuration information in external XML file
• RichTextBox not displaying text
• Converting a string array to a system.drawing.point array