Ahora vamos a Complementos,
Administrador de complementos, y marcamos el Asistente para interfaz de
control ActiveX, luego nuevamente en Complementos hacemos clic sobre el
asistente. Aparecerá la primera pantalla escogiendo Siguiente, aparece:

En este punto yo borré todos los nombres
seleccionados del casillero derecho lo que me simplificó bastante el
código generado. De allí se escoge la propiedad Text como muestra la
figura y se agrega al cuadro de nombres seleccionados, luego el botón
Siguiente

Se escoge Nuevo y en Agregar miembro
personalizado se agrega la propiedad CharAccept y el evento UserError, tal
como muestra la figura, luego el botón siguiente

Aquí asignamos las propiedades, en
este caso asignaremos la propiedad Text del Textbox a nuestra propiedad
Text de TextCharset.
Seleccionamos Text de la lista Nombre
público y seleccionamos luego TextCharset de la lista Control, En la
lista Miembro la propiedad Text se seleccionará automáticamente. Luego
con Siguiente aparece:
El tipo de datos de la propiedad
CharAccept se coloca en Integer y se le establece el valor predeterminado de
0, se coloca siguiente y ya estamos listos para terminar

Cerramos y ya está listo el
"esqueleto" del código creado por el asistente que quedará más
o menos así (excepto por los textos en rojo y rojo oscuro)
'Default Property Values:
Const m_def_CharAccept = 0
'Property Variables:
Dim m_CharAccept As Integer
'Event Declarations:
Event UserError()
'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS
'MappingInfo=txtCharSet,txtCharSet,-1,Text
Public Property Get Text() As String
Text = txtCharSet.Text
End Property
Public Property Let Text(ByVal New_Text As String)
txtCharSet.Text() = New_Text
PropertyChanged "Text"
End Property
'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS
'MemberInfo=7,0,0,0
Public Property Get CharAccept() As Integer
CharAccept = m_CharAccept
End Property
Public Property Let CharAccept(ByVal nNewValue As Integer)
Select Case nNewValue
Case 1 To 2
m_CharAccept = nNewValue
Case Else
m_CharAccept = 0
End Select
PropertyChanged "CharAccept"
End Property
'Inicializar propiedades para control de usuario
Private Sub UserControl_InitProperties()
m_CharAccept = m_def_CharAccept
End Sub
Private Sub txtCharSet_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
Select Case m_CharAccept
Case 0
Exit Sub
Case 1
If KeyAscii >= 48 And KeyAscii <= 57 Then
Exit Sub
Else
KeyAscii = 0
Beep
RaiseEvent UserError
End If
Case 2
If KeyAscii >= 65 And KeyAscii <= 90 Then
Exit Sub
ElseIf KeyAscii >= 97 And KeyAscii <= 122 Then
Exit Sub
Else
KeyAscii = 0
Beep
RaiseEvent UserError
End If
End Select
End Sub
'Cargar valores de propiedad desde el almacén
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
txtCharSet.Text = PropBag.ReadProperty("Text", "")
m_CharAccept = PropBag.ReadProperty("CharAccept", m_def_CharAccept)
End Sub
'Escribir valores de propiedad en el almacén
Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
Call PropBag.WriteProperty("Text",
txtCharSet.Text, "")
Call PropBag.WriteProperty("CharAccept", m_CharAccept, m_def_CharAccept)
End Sub
El código que se muestra no es exactamente el
mismo que aparece generado, se ha agregado el,procedimiento Private Sub txtCharSet_KeyPress(KeyAscii As
Integer)
(marcado en
rojo) y
se han modificado los procedimientos Public Property Let CharAccept(ByVal nNewValue As
Integer) y Public Property Get
CharAccept() As Integer (en
rojo oscuro) de manera que queden como se muestra en el listado
anterior
Finalmente grabamos y compilamos la Ocx, grabándola
en c:\:windows\system para poder cargarla con facilidad