code_junkie

VB.NET: How to reference VB.NET module?

Nov 13th, 2011
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. Public Module CoreModule
  2. Dim R As New System.Random(CInt(Microsoft.VisualBasic.Timer))
  3. Public Function D(ByVal Roll As Integer) As Integer
  4. Return R.Next(0, Roll) + 1
  5. End Function
  6.  
  7. Public Function _1D6() As Integer
  8. Return D(6)
  9. End Function
  10.  
  11. Public Function _2D6() As Integer
  12. Return D(6) + D(6)
  13. End Function
  14.  
  15. Public Function _3D6() As Integer
  16. Return D(6) + D(6) + D(6)
  17. End Function
  18.  
  19. Public Function _4D6() As Integer
  20. Return D(6) + D(6) + D(6) + D(6)
  21. End Function
  22.  
  23. Public Function CRLF() As String
  24. Return Microsoft.VisualBasic.ControlChars.CrLf
  25. End Function
  26. End Module
  27.  
  28. Public NotInheritable Class CoreModule
  29. ' Methods
  30. Shared Sub New()
  31. Public Shared Function _1D6() As Integer
  32. Public Shared Function _2D6() As Integer
  33. Public Shared Function _3D6() As Integer
  34. Public Shared Function _4D6() As Integer
  35. Public Shared Function CRLF() As String
  36. Public Shared Function D(ByVal Roll As Integer) As Integer
  37.  
  38. ' Fields
  39. Private Shared R As Random
  40. End Class
  41.  
  42. public sealed class CoreModule
  43. {
  44. // Fields
  45. private static Random R;
  46.  
  47. // Methods
  48. static CoreModule();
  49. public static int _1D6();
  50. public static int _2D6();
  51. public static int _3D6();
  52. public static int _4D6();
  53. public static string CRLF();
  54. public static int D(int Roll);
  55. }
  56.  
  57. Imports System.Web
  58. Imports System.Web.UI
  59.  
  60. Module ResponseHelper
  61.  
  62. <System.Runtime.CompilerServices.Extension()> _
  63. Public Sub Redirect(ByVal response As Net.HttpWebResponse, _
  64. ByVal url As String, ByVal target As String, _
  65. ByVal windowFeatures As String)
  66.  
  67. If String.IsNullOrEmpty(target) Or _
  68. target.Equals("_self", StringComparison.OrdinalIgnoreCase) And _
  69. String.IsNullOrEmpty(windowFeatures) Then
  70. response.Redirect(url, target, windowFeatures)
  71. Else
  72. Dim page As Page = CType(HttpContext.Current.Handler, Page)
  73. If page Is Nothing Then
  74. Throw New InvalidOperationException("Cannot redirect to new window outside Page context.")
  75. End If
  76. url = page.ResolveClientUrl(url)
  77. Dim script As String
  78. If String.IsNullOrEmpty(windowFeatures) Then
  79. script = "window.open(""{0}"", ""{1}"", ""{2}"";"
  80. Else
  81. script = "window.open(""{0}"", ""{1}"");"
  82. End If
  83. script = String.Format(script, url, target, windowFeatures)
  84. ScriptManager.RegisterStartupScript(page, GetType(Page), "Redirect", script, True)
  85.  
  86. End If
  87. End Sub
  88.  
  89. End Module
Add Comment
Please, Sign In to add comment