We are considering processing using invoke code.
For in variables and out variables, they are defined with edit argument.
The content of the processing returns the alphabet from the excel column value.
For example, if it is 4, D is returned.
If it is 27, it returns AA, and calculates the relationship with the excel column.
edit code
Public Shared Function ConvertToLetter(ByVal ColIndex As Integer) As String
Dim val As String = String.Empty
Dim Alpha As Integer
Dim Beta As Integer
Dim Remainder As Integer
Try
If ColIndex > 26 + (26 * 26) Then
Alpha = Int((ColIndex - 26 - 1) / (26 * 26))
End If
Beta = Int((ColIndex - (Alpha * 26 * 26) - 1) / 26)
Remainder = ColIndex - (Alpha * 26 * 26) - (Beta * 26)
If Alpha > 0 Then
val = Chr(Alpha + 64)
End If
If Beta > 0 Then
val = val & Chr(Beta + 64)
End If
If Remainder > 0 Then
val = val & Chr(Remainder + 64)
End If
Catch ex As Exception
Throw ex
End Try
Return val
End Function
エラー内容:
error contents:
Invoke code : Error compiling code
error BC30289: Statement cannot appear within a method body. End of method assumed. At line 1
error BC30433: Methods in a Module cannot be declared ‘Shared’. At line 1
error BC30512: Option Strict On disallows implicit conversions from ‘Double’ to ‘Integer’. At line 8
error BC30512: Option Strict On disallows implicit conversions from ‘Double’ to ‘Integer’. At line 10
error BC30429: ‘End Sub’ must be preceded by a matching ‘Sub’. At line 26
val = String.Empty
Dim Alpha As Int32
Dim Beta As Int32
Dim Remainder As Int32
Try
If ColIndex > 26 + (26 * 26) Then
Alpha = Decimal.ToInt32(Int(CType((ColIndex - 26 - 1) / (26 * 26),Decimal)))
End If
Beta = Decimal.ToInt32(Int(CType((ColIndex - (Alpha * 26 * 26) - 1) / 26, Decimal)))
Remainder = ColIndex - (Alpha * 26 * 26) - (Beta * 26)
If Alpha > 0 Then
val = Chr(Alpha + 64)
End If
If Beta > 0 Then
val = val & Chr(Beta + 64)
End If
If Remainder > 0 Then
val = val & Chr(Remainder + 64)
End If
Catch ex As Exception
Throw ex
End Try
こんな感じになります。
(厳密に言えば Try ~ Catch ~ End Tryも、そのままThrowするのであれば、単独のActivityで使う範囲ではあまり意味をなさないのですが、消すのも何なので残しておきます)