Microsoft Visual Basics Mac
2014-11-13 Visual Basic(简称VB)是Microsoft公司开发的一种通用的基于对象的程序设计语言,为结构化的、模块化的、面向对象的、包含协助开发环境的事件驱动为机制的可视化程序设计语言。是一种可用于微软自家产品开发的语言。“Visual” 指的是开发图形用户界面 (GUI) 的方法——不需编写大量代码去描述. Use VBA add-ins and macros that you developed for Office for Windows with Office for Mac. Office for Mac for Visual Basic for Applications (VBA) Microsoft Docs Skip to main content. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. Download Visual Studio Code to experience a redefined code editor, optimized for building and debugging modern web and cloud applications. Visual Studio extension development. Create add-ons and extensions for Visual Studio, including new commands, code analyzers, and tool windows. Microsoft remote desktop mac windows 8.1. Add the SDKs and tools you need to create new commands, code analyzers, tool windows, and language services using C#. Then, share your extension with the community in the Visual Studio.
-->The TaskyVB sample application demonstrates how Visual Basic code compiled into a .NET Standard library can be used with Xamarin. Here are some screenshots of the resulting apps running on Android and iOS:
The Android and iOS projects in the example are all written in C#. The user interface for each application is built with native technologies, while the TodoItem
management is provided by the Visual Basic .NET Standard library using an XML file (for demonstration purposes, not a full database).
Sample walkthrough
This guide discusses how Visual Basic has been implemented in theTaskyVBXamarin sample for iOS and Android.
Note
Review the instructions on Visual Basic and .NET Standard before continuing with this guide.
Refer to the Xamarin.Forms using Visual Basic instructions to see how to build an app with shared user-interface Visual Basic code.
VisualBasicNetStandard
Visual Basic .NET Standard libraries can only be created in Visual Studio on Windows.The example library contains the basics of our application in these Visual Basic files:
- TodoItem.vb
- TodoItemManager.vb
- TodoItemRepositoryXML.vb
- XmlStorage.vb
TodoItem.vb
This class contains the business object to be used throughout the application. It will be defined in Visual Basic and shared with the Android and iOS projects that are written in C#.
The class definition is shown here:
The sample uses XML serialization and de-serialization to load and save the TodoItem objects.
TodoItemManager.vb
The Manager class presents the ‘API’ for the portable code. It provides basic CRUD operations for the TodoItem
class, but no implementation of those operations.
The constructor takes an instance of IXmlStorage as a parameter. This allows each platform to provide its own working implementation while still letting the portable code describe other functionality that can be shared.
TodoItemRepository.vb
The repository class contains the logic for managing the list of TodoItem objects. The complete code is shown below – the logic exists mainly to manage a unique ID value across the TodoItems as they are added and removed from the collection.
Note
This code is an example of a very basic data-storage mechanism.It is provided to demonstrate how a .NET Standard library can codeagainst an interface to access platform-specific functionality(in this case, loading and saving an XML file). It it not intended to bea production-quality database alternative.
Android and iOS application projects
Microsoft Visual Basic Virtual Machine
iOS
In the iOS application the TodoItemManager
and the XmlStorageImplementation
are created in the AppDelegate.cs file as shown in this code snippet. The first four lines are just building the path to the file where data will be stored; the final two lines show the two classes being instantiated.
Android
In the Android application the TodoItemManager
and the XmlStorageImplementation
are created in the Application.cs file as shown in this code snippet. The first three lines are just building the path to the file where data will be stored; the final two lines show the two classes being instantiated.
The rest of the application code is primarily concerned with the user interface and using the TaskMgr
class to load and save TodoItem
classes.
Visual Studio 2019 for Mac
Warning
Visual Studio for Mac does NOT support editing the Visual Basic language – there are no menu items for creating Visual Basic projects or files. If you open a .vb there is no language syntax highlighting, autocomplete, or IntelliSense.
Visual Studio 2019 for Mac can compile Visual Studio .NET Standard projects created on Windows, so iOS apps can reference those projects.
Visual Studio 2017 cannot build Visual Basic projects at all.
Summary
This article has demonstrated how to consume Visual Basic code in Xamarin applications using Visual Studio and .NET Standard libraries. Even though Xamarin does not support Visual Basic directly, compiling Visual Basic into a .NET Standard library allows code written with Visual Basic to be included in iOS and Android apps.