Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keyword [With] in delphi

Status
Not open for further replies.

kayDelphi

Programmer
Mar 15, 2010
7
US
Hi
Im try to convert delphi code to VB.NET but i dont understand the meaning of [With] keyword in Delphi. Normals is 2D array, so my question is what does the line in red below do inside the loop

with Normals[I, J] do

thanks
kay

 
Although you said issue solved, thought I'd put my two cents in. "With" is a meaningless expression to me. I hate seeing it used anywhere, it confuses me, exactly why it was confusing you. But for anyone who doesn't know what it does, it makes the following block of code work in the 'context' of whatever you specify for 'with'.

For example,

Code:
with frmMain do begin
  Width:= 100;
  Height:= 100;
  Caption:= 'My Test';
  ShowModal;
end;

as opposed to...

Code:
frmMain.Width:= 100;
frmMain.Height:= 100;
frmMain.Caption:= 'My Test';
frmMain.ShowModal;


JD Solutions
 
And to expand on that you can have multiple variables in your with statement:
Code:
with frmMain, Label1 do begin


end;

I actually prefer VB syntax in this case where you prefix the method or procedure with a period:
Code:
with Something
    .ThisBelongsToSomthing
    ThisDoesNot
    .Does
    DoesNot
end with
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top