A portable class library that does not support many VB methods

I take the VB.Net library and turn it into a portable class library. After I included all the classes in a new project for PCL, Visual Studio started throwing errors for a lot of the common VB syntax, which I thought would still work fine. Some examples:

  • Lcase
  • Instr
  • Left
  • Mid
  • On GoTo error 0
  • Err

Is it possible that there is only some option or enable, I need to make them work?

+1
source share
4 answers

(.NET 4.0, Silverlight, Windows Phone, Xbox) , Microsoft.VisualBasic.dll.

. , Microsoft.VisualBasic.dll, . /vbruntime *: http://msdn.microsoft.com/en-us/library/bb531259.aspx.

.NET 4.5 Windows Store Microsoft.VisualBasic.dll.

, , , VB .NET:

Public Module VisualBasicBridge
    Public Function LCase(value As String) As String

        Return value.ToLower()
    End Function
End Module

On Error, , Microsoft.VisualBasic /vbruntime switch/msbuild.

+2

, (. "" ). equivelants , (ex = SubString, ToUpper, ToLower, IndexOf ..).

+3

, . , , VB 1, .Net 0. , , , VB ( ):

        ''' <summary>
    ''' Simulates the same functionality provide by the traditional 1 based index Mid function.
    ''' </summary>
    ''' <param name="str"></param>
    ''' <param name="startPos"></param>
    ''' <param name="length"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function Mid(ByVal str As String, ByVal startPos As Integer, ByVal length As Integer) As String
        Return str.Substring(startPos - 1, length)
    End Function

/ :

    ''' <summary>
    ''' Extension to the Visual Basic Left function
    ''' </summary>
    ''' <param name="str"></param>
    ''' <param name="length"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function [Left](ByVal str As String, ByVal length As Integer) As String
        Return str.Substring(0, length)
    End Function

    ''' <summary>
    ''' Extension to the Visual Basic Right function
    ''' </summary>
    ''' <param name="str"></param>
    ''' <param name="length"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function [Right](ByVal str As String, ByVal length As Integer) As String
        Return str.Substring(str.Length - length, length)
    End Function

    ''' <summary>
    ''' Determines whether a string is a numeric value.  This implementation uses Decimal.TryParse to produce it value.
    ''' </summary>
    ''' <param name="str"></param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    <Extension()> _
    Public Function [IsNumeric](str As String) As Boolean
        Dim result As Decimal = 0
        Return Decimal.TryParse(str, result)
    End Function

    <Extension()> _
    Public Function LCase(str As String) As String
        Return str.ToLower
    End Function
+2

, Microsoft.VisualBasic. :

LCase = > string.ToLower() InStr = > string.IndexOf() ....

" " try/catch

+1

All Articles