Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "Shift:=" mean in this VB6 code?

Tags:

excel

vb6

I've run across the following line in a VB6 application.

mobjParentWrkBk.ExcelWorkBook.Application.Selection.Insert Shift:=xlToRight

Unfortunately Google and other search engines have not been very useful as they seem to omit the := part.

What would be a C# equivalent?

like image 266
Esteban Brenes Avatar asked Oct 22 '08 20:10

Esteban Brenes


1 Answers

This is Visual Basic syntax for optional named parameters. The Insert function has a parameter named Shift, which is being specified.

C#, as far as I know, doesn't have an equivalent for optional named parameters. Instead, you'd need to call the Insert method, specifying Type.Missing for all parameters other than Shift.

See also the following StackOverflow question: VB.NET := Operator

UPDATE (2008-10-29):

C# 4.0 is set to introduce optional and named parameters. See this blog entry on codebetter.com.

like image 107
John Rudy Avatar answered Oct 04 '22 20:10

John Rudy