Visual Basic Goes Mobile with Portable Libraries

Craig Dunn

Since the dawn of iPhone, Visual Basic developers have asked the enduring question, “Can I play too?” With our recent announcement of full support for Portable Class Library Projects as part of our participation in the Visual Studio 2013 launch, the answer is now a resounding “Yes! (Kinda.)”

Portable Class Libraries enable .NET developers to easily share code across iOS, Android, Windows Phone and Windows Store apps. One of the hidden gems in Portable Class Libraries is that you can create portable Visual Basic libraries which can then be incorporated into Xamarin.iOS and Xamarin.Android apps. While this doesn’t constitute full support for Visual Basic, it does mean that a significant portion of your iOS and Android application logic can now be written in VB.

To see how easy it is to bring your Visual Basic code into Xamarin projects via a Portable Library, visit our documentation portal for a complete example of creating a Visual Basic library and adding it to iOS, Android and Windows Phone apps.

    Public Function SaveTask(item As Task) As Integer
        Dim max As Integer = 0

        If _tasks.Count > 0 Then
            max = _tasks.Max(Function(t As Task) t.ID)
        End If
        If item.ID = 0 Then
            item.ID = ++max
            Dim j = _tasks.Where(Function(t) t.ID = item.ID).First()
            j = item
        End If
        _storage.WriteXml(_tasks, _filename)
        Return max
    End Function

Aside from giving VB developers the opportunity to eschew semicolons and enjoy the comfort of underscore concatenated new lines and keyword constrained conditional scoping, reusable Visual Basic application logic affords a serious opportunity for VB coders to more easily transfer their existing code and skills to mobile. If you have existing Visual Basic.NET libraries, use the Xamarin Mobility Scanner to see how much of your existing Visual Basic can be brought into the mobile world.

Discuss this blog post in the Xamarin Forums


Discussion is closed.

Feedback usabilla icon