{"id":20395,"date":"2015-08-25T14:51:14","date_gmt":"2015-08-25T18:51:14","guid":{"rendered":"https:\/\/blog.xamarin.com\/?p=20395"},"modified":"2015-08-25T14:51:14","modified_gmt":"2015-08-25T18:51:14","slug":"mobile-apps-with-visual-basic-xamarin-forms","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/xamarin\/mobile-apps-with-visual-basic-xamarin-forms\/","title":{"rendered":"Mobile Apps with Visual Basic &amp; Xamarin.Forms"},"content":{"rendered":"<p>If you are a Visual Basic developer, your options for becoming a mobile developer have historically been limited to targeting Windows Phone; however, with Xamarin.Forms, Portable Class Libraries, and Visual Studio, developing iOS and Android apps entirely in Visual Basic has become a real possibility.<\/p>\n<p><a href=\"https:\/\/blog.xamarin.com\/visual-basic-goes-mobile-with-portable-libraries\/\">Last year<\/a> I wrote about how Visual Basic Portable Class Libraries (PCLs) <a href=\"https:\/\/blog.xamarin.com\/visual-basic-goes-mobile-with-portable-libraries\/\">can be used in Xamarin apps<\/a>. Xamarin.iOS and Xamarin.Android can access business logic written in Visual Basic PCLs, while writing the platform-specific code (including the user interface) in C# (or F#) on the Xamarin platform.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/44\/2019\/03\/visualbasic-blog-hero.png\" alt=\"Visual Basic Xamarin.Forms\" class=\"alignnone size-medium wp-image-20397\" \/><\/p>\n<p>Since then we\u2019ve released Xamarin.Forms, which makes it possible for an entire app&mdash;from business logic to user interface&mdash;to be written in a PCL and shared across platforms. This means that it\u2019s become possible to write entire mobile applications in Visual Basic in Visual Studio using Xamarin.Forms. The Xamarin developer portal has <a href=\"http:\/\/developer.xamarin.com\/guides\/cross-platform\/application_fundamentals\/pcl\/portable_visual_basic_net\/xamarin-forms\/\">instructions on creating a Visual Basic project<\/a> from the Xamarin.Forms new project template. A \u201cBasic\u201d <code>App<\/code> class is shown here:<\/p>\n<pre class=\"lang:vb decode:true\">\nPublic Class App\n    Inherits Application\n\n    Public Sub New()\n        Dim label = New Label With {.XAlign = TextAlignment.Center,\n                                    .FontSize = Device.GetNamedSize(NamedSize.Medium, GetType(Label)),\n                                    .Text = &quot;Welcome to Xamarin.Forms with Visual Basic.NET&quot;}\n\n        Dim stack = New StackLayout With {\n            .VerticalOptions = LayoutOptions.Center\n        }\n        stack.Children.Add(label)\n\n        Dim page = New ContentPage\n        page.Content = stack\n        MainPage = page\n\n    End Sub\n<\/pre>\n<p>Once you\u2019ve created a new project and converted it to Visual Basic (or just started with <a href=\"https:\/\/github.com\/xamarin\/mobile-samples\/tree\/master\/VisualBasic\/XamarinFormsVB\">the sample<\/a>) your entire application can be written in Visual Basic. The code below represents a simple <code>ContentPage<\/code> written in Visual Basic. You can use this as a basis for new pages in your apps:<\/p>\n<pre class=\"lang:vb decode:true\">\nPublic Class Page2\n    Inherits ContentPage\n\n    Public Sub New()\n        Dim label = New Label With {.XAlign = TextAlignment.Center,\n                                    .FontSize = Device.GetNamedSize(NamedSize.Medium, GetType(Label)),\n                                    .Text = &quot;Visual Basic  ContentPage&quot;}\n\n        Dim button = New Button With {.Text = &quot;Click me&quot;}\n        AddHandler button.Clicked, Async Sub(sender, e)\n                                       Await DisplayAlert(&quot;Hello from VB&quot;, &quot;Visual Basic.NET is back!&quot;, &quot;Thanks&quot;)\n                                   End Sub\n\n        Dim stack = New StackLayout With {\n            .VerticalOptions = LayoutOptions.Center\n        }\n        stack.Children.Add(label)\n        stack.Children.Add(button)\n\n        Content = stack\n    End Sub\n\nEnd Class \n<\/pre>\n<p>Xamarin doesn&#8217;t implement support for the Visual Basic language directly, so you can\u2019t use Xamarin Studio for these projects; however, if you&#8217;re a Visual Basic programmer, or have existing Visual Basic code you\u2019d like to mobilize, there&#8217;s never been a better time to <a href=\"http:\/\/developer.xamarin.com\/guides\/cross-platform\/application_fundamentals\/pcl\/portable_visual_basic_net\/xamarin-forms\/\">get started with mobile development with Xamarin.Forms!<\/a>  And, of course, if you <strong>have<\/strong> published a Windows Phone application written in Visual Basic, there&#8217;s still time to take advantage of our <a href=\"https:\/\/blog.xamarin.com\/free-xamarin-subscriptions-for-windows-phone-developers\/\">free subscriptions for Windows Phone Developers<\/a> promotion before August 31, 2015.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are a Visual Basic developer, your options for becoming a mobile developer have historically been limited to targeting Windows Phone; however, with Xamarin.Forms, Portable Class Libraries, and Visual Studio, developing iOS and Android apps entirely in Visual Basic has become a real possibility. Last year I wrote about how Visual Basic Portable Class [&hellip;]<\/p>\n","protected":false},"author":570,"featured_media":20397,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[2],"tags":[4,16],"class_list":["post-20395","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developers","tag-xamarin-platform","tag-xamarin-forms"],"acf":[],"blog_post_summary":"<p>If you are a Visual Basic developer, your options for becoming a mobile developer have historically been limited to targeting Windows Phone; however, with Xamarin.Forms, Portable Class Libraries, and Visual Studio, developing iOS and Android apps entirely in Visual Basic has become a real possibility. Last year I wrote about how Visual Basic Portable Class [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/20395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/users\/570"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/comments?post=20395"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/posts\/20395\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/media?parent=20395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/categories?post=20395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/xamarin\/wp-json\/wp\/v2\/tags?post=20395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}