Advertisement
hiro1357

VB.NET DLL Skeleton

Dec 2nd, 2015
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. ---make.cmd---
  2. @echo off
  3. for /f "usebackq" %%d in (`dir/w %WINDIR%\Microsoft.NET\Framework ^| findstr [v`) do set dotnetdir=%%d
  4. set dotnetdir=%dotnetdir:[=%
  5. set dotnetdir=%dotnetdir:]=%
  6. rem echo %dotnetdir%
  7. set VBCOMPILER=%windir%\Microsoft.NET\Framework\%dotnetdir%\vbc.exe
  8.  
  9. %VBCOMPILER% /target:library /platform:anycpu /out:MyModule.dll MyModule.vb
  10. %VBCOMPILER% /target:winexe /platform:anycpu /r:MyModule.dll /main:Form1 /out:test.exe Main.vb
  11. pause
  12. ---end make.cmd---
  13.  
  14. ---MyModule.vb---
  15. Imports System
  16.  
  17. Public Class MyModule
  18. Private str As String
  19.  
  20. Public Sub New()
  21. str = "new"
  22. End Sub
  23.  
  24. Public Function SetStr(s As String) As Integer
  25. str = s
  26. Return 0
  27. End Function
  28.  
  29. Public Function GetStr() As String
  30. Return str
  31. End Function
  32. End Class
  33. ---end MyModule.vb---
  34.  
  35. ---Main.vb---
  36. Imports System
  37. Imports System.Windows.Forms
  38.  
  39. Public Class Form1
  40. Inherits Form
  41.  
  42. Public TextBox1 As TextBox
  43. Public WithEvents Button1 As Button
  44. Public WithEvents Button2 As Button
  45. Public MyModule1 As MyModule
  46.  
  47. Public Sub New()
  48. MyModule1 = New MyModule
  49.  
  50. Me.Width = 335
  51. Me.Height = 100
  52. Me.Text = "sample"
  53.  
  54. TextBox1 = New TextBox
  55. TextBox1.Top = 10
  56. TextBox1.Left = 10
  57. TextBox1.Width = 150
  58. Me.Controls.Add(TextBox1)
  59.  
  60. Button1 = New Button
  61. Button1.Top = 10
  62. Button1.Left = 165
  63. Button1.Text = "Set"
  64. Button1.Width = 70
  65. Me.Controls.Add(Button1)
  66.  
  67. Button2 = New Button
  68. Button2.Top = 10
  69. Button2.Left = 240
  70. Button2.Text = "Get"
  71. Button2.Width = 70
  72. Me.Controls.Add(Button2)
  73.  
  74. End Sub
  75.  
  76. Private Sub Button1_Click(Byval sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  77. MyModule1.SetStr(TextBox1.Text)
  78. End Sub
  79.  
  80. Private Sub Button2_Click(Byval sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
  81. MessageBox.Show(MyModule1.GetStr())
  82. End Sub
  83.  
  84. Shared Sub Main()
  85. Application.EnableVisualStyles()
  86. Application.Run(New Form1)
  87. End Sub
  88. End Class
  89. ---end Main.vb---
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement