VB.NET
'''
<summary>
'''
VB6のMid関数を実現する方法
'''
</summary>
'''
<param name="strValue"></param>
'''
<param name="intStart"></param>
'''
<returns></returns>
Public Shared Function
Mid(strValue As String, intStart As Integer) As String
If
intStart <= strValue.Length Then
Return
strValue.Substring(intStart - 1)
End If
Return String.Empty
End Function
'''
<summary>
'''
VB6のMid関数を実現する方法(文字長指定)
'''
</summary>
'''
<param name="strValue"></param>
'''
<param name="intStart"></param>
'''
<param name="intLen"></param>
'''
<returns></returns>
Public Shared Function
Mid(strValue As String, intStart As Integer, intLen As Integer) As String
If
intStart <= strValue.Length Then
If
intStart + intLen - 1 <= strValue.Length Then
Return strValue.Substring(intStart - 1, intLen)
End If
Return
strValue.Substring(intStart - 1)
End If
Return String.Empty
End Function
C#
///
<summary>
/// VB6のMid関数を実現する方法
///
</summary>
///
<param name="strValue"></param>
///
<param name="intStart"></param>
///
<returns></returns>
public static string
Mid(string strValue, int intStart)
{
if
(intStart <= strValue.Length)
{
return strValue.Substring(intStart - 1);
}
return string.Empty;
}
'''
<summary>
'''
VB6のMid関数を実現する方法 (文字長指定)
'''
</summary>
'''
<param name="strValue"></param>
'''
<param name="intStart"></param>
'''
<param name="intLen"></param>
'''
<returns></returns>
Public Shared Function
Mid(strValue As String, intStart As Integer, intLen As Integer) As String
If
intStart <= strValue.Length Then
If
intStart + intLen - 1 <= strValue.Length Then
Return strValue.Substring(intStart - 1, intLen)
End If
Return
strValue.Substring(intStart - 1)
End If
Return String.Empty
End Function