Linux(mono)でVBクラス

今回もVBです。

クラスを作って中に、Mainを組み込みます。

takk@deb9:~/vbtest$ cat -n test.vb
     1  Imports System.Console
     2  Public Class TestClass
     3          <STAThread()> _
     4          Shared Sub Main()
     5                  WriteLine("Hello")
     6          End Sub
     7  End Class
takk@deb9:~/vbtest$

ビルド

takk@deb9:~/vbtest$ vbnc test.vb
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.0.1 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

Assembly 'test, Version=0.0, Culture=neutral, PublicKeyToken=null' saved successfully to '/home/takk/vbtest/test.exe'.
Compilation successful
Compilation took 00:00:00.7547620
takk@deb9:~/vbtest$

実行。

takk@deb9:~/vbtest$ mono test.exe
Hello
takk@deb9:~/vbtest$

要領を得れば簡単ですね。

では、Newを実装します。

takk@deb9:~/vbtest$ cat -n test.vb
     1  Imports System.Console
     2  Public Class TestClass
     3          <STAThread()> _
     4          Shared Sub Main()
     5                  dim app = new TestClass()
     6          End Sub
     7
     8
     9          Sub New()
    10                  WriteLine("Hello")
    11          End Sub
    12  End Class
takk@deb9:~/vbtest$

実行。

takk@deb9:~/vbtest$ vbnc test.vb
Visual Basic.Net Compiler version 0.0.0.5943 (Mono 4.0.1 - tarball)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

/home/takk/vbtest/test.vb (5,10) : warning VBNC42020: Variable declaration without an 'As' clause; type of Object assumed.
Assembly 'test, Version=0.0, Culture=neutral, PublicKeyToken=null' saved successfully to '/home/takk/vbtest/test.exe'.
There were 0 errors and 1 warnings.
Compilation successful
Compilation took 00:00:00.5261230
takk@deb9:~/vbtest$
takk@deb9:~/vbtest$ mono test.exe
Hello
takk@deb9:~/vbtest$

コメント

タイトルとURLをコピーしました