Hello all, I've having some issues converting this class to VB.NET, can someone help?
http://davidkean.net/archive/2004/09/06/150.aspx
Thanks.
Printable View
Hello all, I've having some issues converting this class to VB.NET, can someone help?
http://davidkean.net/archive/2004/09/06/150.aspx
Thanks.
I am not sure about this, just typed from top of my head.
VB Code:
Namespace System.Windows.Forms Public Class PasswordTextBox Inherits TextBox Private Const ES_PASSWORD As Integer = 32 'No need for this, will behave like a default constructor 'And in VB, the keyword for constructor is [New] as opposed 'classname in C# Public Sub New() End Sub 'CreateParams is an in-built Property, and used under 'SecurityPermission Attribute Protected Overrides Property CreateParams() As CreateParams <SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode:=True)> _ Get 'Base will become MyBase Dim parameters As CreateParams = MyBase.CreateParams 'Or will replace | parameters.Style = (parameters.Style Or ES_PASSWORD) Return parameters End Get End Property End Class End Namespace
Thanks, I will try it first thing monday morning.
Harsh Gupta's is correct except for the "ReadOnly" specifier. A bug in Instant VB was also omitting the "ReadOnly" specifer for this particular case - this is fixed now.
VB Code:
#Region "Using directives" Imports System Imports System.Windows.Forms Imports System.Security Imports System.Security.Permissions #End Region Namespace System.Windows.Forms Public Class PasswordTextBox Inherits TextBox Private Const ES_PASSWORD As Integer = 32 Public Sub New() End Sub Protected Overrides ReadOnly Property CreateParams() As CreateParams <SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode:=True)> _ Get Dim parameters As CreateParams = MyBase.CreateParams parameters.Style = (parameters.Style Or ES_PASSWORD) Return parameters End Get End Property End Class End Namespace