Skip to Content
0
Former Member
Dec 01, 2009 at 12:38 PM

Password TextBox Using ActiveX Control

119 Views

Hi All,

I have several time seen the problem: how can make a password box or textbox with masked with * characters.

So possible solution could be to create a 2 textboxes and manage them somehow. Here the question is: how to manage the del, backspace characters.

Information for MS Office users: in MS Forms 2.0 library, the TextBox control can be called as ActiveX object...

for distribution of Forms 2.0 library please the the article KB224305 at microsoft site.

To do to Create a * masked TextBox

1. Add the Microsoft Forms 2.0 Libary to Your Visual Studio Project

- Click On My Project and Add Refernce

- Select COM Type (COM Tab) and from the avaiable list choose Mircosoft Form 2.0 Object Libary (C:WindowsSystem32FM20.dll)

2. You should define a global Object in your addon class for the Password TextBox Object (local is not working)


Friend Class Addon
  '
  Private oMyPwdBox as Microsoft.Vbe.Interop.Forms.TextBox ' This is the name of the Forms 2.0 Inpterop Libraries
  '...


3. When you generating the form, you can use Windows.Forms.1 as an ActiveX ClassId and Now Assign the Global object to the ActiveX control, and set up a few properties...

oItem = oForm.Items.Add("MyPwdBox", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X)
oItem.Top = 30
oItem.Left = 100
oItem.Width = 100
oItem.Height = 19
Dim oActiveX As SAPbouiCOM.ActiveX = oItem.Specific
oActiveX.ClassID = "Forms.TextBox.1"
oTextBox = oActiveX.Object
oTextBox.BorderStyle = Microsoft.Vbe.Interop.Forms.fmBorderStyle.fmBorderStyleSingle
oTextBox.PasswordChar = "*"
oTextBox.SelectionMargin = False

4. In the EventHandler procedure, you can use the global object to manage the password value...


Private Sub sbo_application_ItemEvent(ByVal FormUID As String, ByRef pVal As SAPbouiCOM.ItemEvent, ByRef BubbleEvent As Boolean) Handles sbo_application.ItemEvent
  ..
  If oTextBox IsNot Nothing Then
    sbo_application.MessageBox(oTextBox.String)
  End If
  ..

Best Regards,

János