>Visual Basic 2015は2015年に.NET Framework 4.6とともに公開された。Roslynと呼ばれるコンパイラレイヤーにより、Visual C#と同等のIDE機
>能を備えるに至った。
(C#の開発責任者がVBも兼任し約2000万行を使って開発したときいている。)
--------------------------------------------------------------------------------
VBの場合の ラムダ式 の書き方です。VBはC#より容易に取り組む事が出来てC#と同様のことが出来るようになりました。
C#の場合と同様のVBのプログラムです。
vb1.vb
Module Module1
Private f As Form
Private t As TextBox
Private b As Button
Sub Main()
f = New Form()
t = New TextBox()
b = New Button()
f.Text = "Form"
t.Text = "TextBox: ABCDE"
b.Text = "Button"
f.Size = new Size(300, 200)
f.Location = new Point(500, 400)
t.Location = new Point(30, 20)
b.Location = new Point(30, 60)
f.Controls.Add(t)
f.Controls.Add(b)
AddHandler b.Click, Sub(sender, e) t.Text = "C# ボタン: Hello!"
Application.Run(f)
End Sub
End Module
AddHandler b.Click, Sub(sender, e) t.Text = "C# ボタン: Hello!"の部分が 「ラムダ式」 です。
VBの応答ファイルには
/imports:System
/imports:Microsoft.VisualBasic
/imports:System.Linq
/imports:System.Xml.Linq
が書かれているのでソースには書く必要がありません。追加のimportsはPowerShell, バッチファイル側に書くことが出来ます。
vb.rsp
# This file contains command-line options that the VB
# command line compiler (VBC) will process as part
# of every compilation, unless the "/noconfig" option
# is specified.
# Reference the common Framework libraries
/r:Accessibility.dll
/r:System.Configuration.dll
/r:System.Configuration.Install.dll
/r:System.Data.dll
/r:System.Data.OracleClient.dll
/r:System.Deployment.dll
/r:System.Design.dll
/r:System.DirectoryServices.dll
/r:System.dll
/r:System.Drawing.Design.dll
/r:System.Drawing.dll
/r:System.EnterpriseServices.dll
/r:System.Management.dll
/r:System.Messaging.dll
/r:System.Runtime.Remoting.dll
/r:System.Runtime.Serialization.Formatters.Soap.dll
/r:System.Security.dll
/r:System.ServiceProcess.dll
/r:System.Transactions.dll
/r:System.Web.dll
/r:System.Web.Mobile.dll
/r:System.Web.RegularExpressions.dll
/r:System.Web.Services.dll
/r:System.Windows.Forms.Dll
/r:System.XML.dll
/r:System.Workflow.Activities.dll
/r:System.Workflow.ComponentModel.dll
/r:System.Workflow.Runtime.dll
/r:System.Runtime.Serialization.dll
/r:System.ServiceModel.dll
/r:System.Core.dll
/r:System.Xml.Linq.dll
/r:System.Data.Linq.dll
/r:System.Data.DataSetExtensions.dll
/r:System.Web.Extensions.dll
/r:System.Web.Extensions.Design.dll
/r:System.ServiceModel.Web.dll
# Import System and Microsoft.VisualBasic
/imports:System
/imports:Microsoft.VisualBasic
/imports:System.Linq
/imports:System.Xml.Linq
/optioninfer+