Results 1 to 4 of 4

Thread: Help converting this class to VB.NET

  1. #1

    Thread Starter
    Lively Member Xcoder's Avatar
    Join Date
    Jan 2004
    Posts
    120

    Help converting this class to VB.NET

    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.
    Last edited by Xcoder : 09-10-2001 at 12:45 AM.

  2. #2
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: Help converting this class to VB.NET

    I am not sure about this, just typed from top of my head.
    VB Code:
    1. Namespace System.Windows.Forms
    2.     Public Class PasswordTextBox
    3.         Inherits TextBox
    4.         Private Const ES_PASSWORD As Integer = 32
    5.  
    6.         'No need for this, will behave like a default constructor
    7.                 'And in VB, the keyword for constructor is [New] as opposed
    8.                 'classname in C#
    9.                 Public Sub New()
    10.         End Sub
    11.  
    12.         'CreateParams is an in-built Property, and used under
    13.                 'SecurityPermission Attribute
    14.                 Protected Overrides Property CreateParams() As CreateParams
    15.             <SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode:=True)> _
    16.             Get
    17.                 'Base will become MyBase
    18.                                 Dim parameters As CreateParams = MyBase.CreateParams
    19.                                
    20.                                 'Or will replace |
    21.                 parameters.Style = (parameters.Style Or ES_PASSWORD)
    22.  
    23.                 Return parameters
    24.             End Get
    25.         End Property
    26.     End Class
    27. End Namespace
    Show Appreciation. Rate Posts.

  3. #3

    Thread Starter
    Lively Member Xcoder's Avatar
    Join Date
    Jan 2004
    Posts
    120

    Re: Help converting this class to VB.NET

    Thanks, I will try it first thing monday morning.
    Last edited by Xcoder : 09-10-2001 at 12:45 AM.

  4. #4
    Fanatic Member
    Join Date
    Jan 2006
    Posts
    710

    Re: Help converting this class to VB.NET

    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:
    1. #Region "Using directives"
    2.  
    3. Imports System
    4. Imports System.Windows.Forms
    5. Imports System.Security
    6. Imports System.Security.Permissions
    7.  
    8. #End Region
    9.  
    10. Namespace System.Windows.Forms
    11.     Public Class PasswordTextBox
    12.         Inherits TextBox
    13.         Private Const ES_PASSWORD As Integer = 32
    14.  
    15.         Public Sub New()
    16.         End Sub
    17.  
    18.         Protected Overrides ReadOnly Property CreateParams() As CreateParams
    19.             <SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode:=True)> _
    20.             Get
    21.                 Dim parameters As CreateParams = MyBase.CreateParams
    22.  
    23.                 parameters.Style = (parameters.Style Or ES_PASSWORD)
    24.  
    25.                 Return parameters
    26.             End Get
    27.         End Property
    28.     End Class
    29. End Namespace
    Last edited by David Anton; Oct 14th, 2006 at 09:56 PM. Reason: wording adjustment
    David Anton
    Convert between VB, C#, C++, & Java
    www.tangiblesoftwaresolutions.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width