What does “Shift: =” mean in this VB6 code?

I skipped the next line in a VB6 application.

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

Unfortunately, Google and other search engines are not very useful as they seem to disregard: = part.

What is the C # equivalent?

+5
source share
4 answers

This is the Visual Basic syntax for optional named parameters. The function Inserthas a parameter with the name Shiftthat is specified.

C #, to my knowledge, has no equivalent for optional named parameters. Instead, you need to call the method Insert, specifying Type.Missingfor all parameters other than Shift.

. StackOverflow: VB.NET: =

(2008-10-29):

# 4.0 . codebetter.com.

+14

, .

( 'o'), . , VB6 "" .

, .

, , VBA Optional (capital 'O'). , , ( ) VBA , Optional:

Private Function TimesTen( _
    ByVal Value As Long, _
    Optional ByVal Factor As Long = 10 _
) As Long
  TimesTen = Value * Factor
End Function

VBA ( Optional VBA, #.NET, Type.Missing Optional):

  MsgBox TimesTen(Value:=9)

"" (?), , :

  MsgBox TimesTen(Factor:=11, Value:=9)

"" :

  MsgBox TimesTen(Value:=9, 11)

, VBA , VB6, ? , , VBA, MS Office, (?) , VBA .

+8

VB6 VB.net . # .

VB6/VB.net: Shift: = xlToRight .

. public sub mymethod ( a integer = -1, b integer = 1) ... end sub

mymethod (b: = 10)

# 2


void Shift()
{
defaultDirection = directionEnum.Left;
Shift(defaultDirection);
}

void Shift(directionEnum direction)
{
}

1 . , .
DoSomethingWithData (CustomerData: = , SortDirection: = )

, .

+2

Excel , . "", . Excel:

=======

, .

expression.Insert(Shift, CopyOrigin)

. , Range.

. , . XlInsertShiftDirection: xlShiftToRight xlShiftDown. , Microsoft Excel .

CopyOrigin. .

===========

If you do not have certain constants, you can substitute the following numbers

xlShiftDown: -4121 xlShiftToLeft: -4159 xlShiftToRight: -4161 xlShiftUp: -4162

+1
source

All Articles