VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX" Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TABCTL32.OCX" Begin VB.Form frmPSIs BorderStyle = 3 'Fixed Dialog Caption = "PSIs" ClientHeight = 5655 ClientLeft = 45 ClientTop = 330 ClientWidth = 7980 Icon = "PSIs.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MDIChild = -1 'True MinButton = 0 'False ScaleHeight = 5655 ScaleWidth = 7980 ShowInTaskbar = 0 'False Begin VB.CommandButton cmdAceptar Cancel = -1 'True Caption = "&Aceptar" Height = 375 Left = 6480 TabIndex = 0 Top = 5160 Width = 1335 End Begin TabDlg.SSTab SSTab1 Height = 5655 Left = 0 TabIndex = 1 Top = 0 Width = 7965 _ExtentX = 14049 _ExtentY = 9975 _Version = 393216 Style = 1 Tabs = 2 TabHeight = 520 TabCaption(0) = "PSIs" TabPicture(0) = "PSIs.frx":0E42 Tab(0).ControlEnabled= -1 'True Tab(0).Control(0)= "Label1" Tab(0).Control(0).Enabled= 0 'False Tab(0).Control(1)= "Label2" Tab(0).Control(1).Enabled= 0 'False Tab(0).Control(2)= "Label6" Tab(0).Control(2).Enabled= 0 'False Tab(0).Control(3)= "Label7" Tab(0).Control(3).Enabled= 0 'False Tab(0).Control(4)= "lstPSIs" Tab(0).Control(4).Enabled= 0 'False Tab(0).Control(5)= "txtLarga" Tab(0).Control(5).Enabled= 0 'False Tab(0).Control(6)= "Frame1" Tab(0).Control(6).Enabled= 0 'False Tab(0).Control(7)= "txtCorta" Tab(0).Control(7).Enabled= 0 'False Tab(0).Control(8)= "txtGrafico" Tab(0).Control(8).Enabled= 0 'False Tab(0).Control(9)= "txtSonido" Tab(0).Control(9).Enabled= 0 'False Tab(0).Control(10)= "cmdNuevo" Tab(0).Control(10).Enabled= 0 'False Tab(0).Control(11)= "cmdBorrar" Tab(0).Control(11).Enabled= 0 'False Tab(0).Control(12)= "cmdModificar" Tab(0).Control(12).Enabled= 0 'False Tab(0).ControlCount= 13 TabCaption(1) = "Propiedades Usuario" TabPicture(1) = "PSIs.frx":0E5E Tab(1).ControlEnabled= 0 'False Tab(1).Control(0)= "cmdNuevaUsr" Tab(1).Control(1)= "cmdBorrarUsr" Tab(1).Control(2)= "Frame2" Tab(1).ControlCount= 3 Begin VB.Frame Frame2 Height = 4695 Left = -74880 TabIndex = 24 Top = 360 Width = 7695 Begin VB.CommandButton cmdArray Caption = "..." Height = 285 Index = 0 Left = 7080 TabIndex = 28 Top = 240 Visible = 0 'False Width = 285 End Begin VB.TextBox txtPropUsr ForeColor = &H80000012& Height = 285 Index = 0 Left = 2040 TabIndex = 26 Top = 240 Visible = 0 'False Width = 4935 End Begin VB.VScrollBar VScroll1 Enabled = 0 'False Height = 4575 Left = 7440 Max = 0 TabIndex = 25 Top = 120 Width = 255 End Begin VB.Label lblPropUsr Caption = "Propiedad" BeginProperty Font Name = "Arial" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Index = 0 Left = 120 TabIndex = 27 Top = 240 Visible = 0 'False Width = 1935 End End Begin VB.CommandButton cmdModificar Caption = "&Modificar" Height = 375 Left = 3000 TabIndex = 18 Top = 5160 Width = 1335 End Begin VB.CommandButton cmdBorrar Caption = "&Borrar" Height = 375 Left = 1560 TabIndex = 17 Top = 5160 Width = 1335 End Begin VB.CommandButton cmdNuevo Caption = "&Añadir" Height = 375 Left = 120 TabIndex = 16 Top = 5160 Width = 1335 End Begin VB.TextBox txtSonido Height = 285 Left = 5160 TabIndex = 15 Top = 4800 Width = 2655 End Begin VB.TextBox txtGrafico Height = 285 Left = 5160 TabIndex = 14 Top = 4440 Width = 2655 End Begin VB.TextBox txtCorta Height = 285 Left = 4440 TabIndex = 13 Top = 600 Width = 3375 End Begin VB.Frame Frame1 Caption = "Propiedades" Height = 2055 Left = 4440 TabIndex = 5 Top = 2280 Width = 3375 Begin VB.ListBox lstProp Height = 960 ItemData = "PSIs.frx":0E7A Left = 120 List = "PSIs.frx":0E87 Style = 1 'Checkbox TabIndex = 9 Top = 960 Width = 3135 End Begin VB.TextBox txtTam Height = 285 Left = 2520 TabIndex = 8 Text = "0" Top = 240 Width = 735 End Begin VB.TextBox txtPeso Height = 285 Left = 840 TabIndex = 7 Text = "0" Top = 240 Width = 855 End Begin VB.ComboBox lstLoc Height = 315 Left = 960 TabIndex = 6 Top = 600 Width = 2295 End Begin VB.Label Label5 Caption = "Tamaño" Height = 255 Left = 1800 TabIndex = 12 Top = 240 Width = 735 End Begin VB.Label Label4 Caption = "Peso" Height = 255 Left = 120 TabIndex = 11 Top = 240 Width = 615 End Begin VB.Label Label3 Caption = "Loc. inicial" Height = 255 Left = 120 TabIndex = 10 Top = 600 Width = 1215 End End Begin VB.TextBox txtLarga Height = 975 Left = 4440 MultiLine = -1 'True ScrollBars = 2 'Vertical TabIndex = 4 Top = 1200 Width = 3375 End Begin VB.CommandButton cmdBorrarUsr Caption = "&Borrar" Height = 375 Left = -73440 TabIndex = 3 Top = 5160 Width = 1335 End Begin VB.CommandButton cmdNuevaUsr Caption = "&Añadir" Height = 375 Left = -74880 TabIndex = 2 Top = 5160 Width = 1335 End Begin MSComctlLib.ListView lstPSIs Height = 4695 Left = 120 TabIndex = 19 Top = 360 Width = 4215 _ExtentX = 7435 _ExtentY = 8281 View = 3 LabelEdit = 1 LabelWrap = -1 'True HideSelection = 0 'False FullRowSelect = -1 'True _Version = 393217 ForeColor = -2147483640 BackColor = -2147483643 BorderStyle = 1 Appearance = 1 NumItems = 3 BeginProperty ColumnHeader(1) {BDD1F052-858B-11D1-B16A-00C0F0283628} Text = "Nº" Object.Width = 882 EndProperty BeginProperty ColumnHeader(2) {BDD1F052-858B-11D1-B16A-00C0F0283628} SubItemIndex = 1 Text = "Nombre" Object.Width = 2646 EndProperty BeginProperty ColumnHeader(3) {BDD1F052-858B-11D1-B16A-00C0F0283628} SubItemIndex = 2 Text = "Adjetivo" Object.Width = 2646 EndProperty End Begin VB.Label Label7 Caption = "Sonido" Height = 255 Left = 4440 TabIndex = 23 Top = 4800 Width = 615 End Begin VB.Label Label6 Caption = "Gráfico" Height = 255 Left = 4440 TabIndex = 22 Top = 4440 Width = 615 End Begin VB.Label Label2 Caption = "Descripción larga" Height = 255 Left = 4440 TabIndex = 21 Top = 960 Width = 3375 End Begin VB.Label Label1 Caption = "Descripción corta" Height = 255 Left = 4440 TabIndex = 20 Top = 360 Width = 3255 End End End Attribute VB_Name = "frmPSIs" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Const MAX_PROP_USR = 17 ' nº máx. de propiedades de usuario ' que caben en pantalla Private Sub cmdArray_Click(index As Integer) Load frmEdArray frmEdArray.Inicializa txtPropUsr(index).Text frmEdArray.Show vbModal txtPropUsr(index).Text = frmEdArray.sArray BloqueaArray index Unload frmEdArray End Sub Private Sub cmdBorrar_Click() Dim c As String, sNombre As String Dim i As Long, lPSI As Long Dim iOpc As Integer If lstPSIs.ListItems.Count < 1 Then Exit Sub End If ' coge número del PSI que está seleccionado c = lstPSIs.SelectedItem.key ' la clave tiene el formato Pnnn, donde 'nnn' es el número del PSI lPSI = CLng(Mid(c, 2)) If lPSI < 0 Then Exit Sub End If iOpc = MsgBox("Se va a borrar el PSI seleccionado. ¿Quieres continuar?", _ vbYesNo + vbQuestion, "AVISO") If iOpc <> vbYes Then Exit Sub End If sNombre = JuntaNombreAdj(PSIs(lPSI).Nombre, PSIs(lPSI).Adjetivo) BorrarPSI lPSI ActualizarListaPSI ActualizarDatosPSI ' revisamos los objetos que tengan como contenedor este y los actualizamos For i = 0 To UBound(Objetos) If Objetos(i).TipoContenedor = OBJ_CONTPSI And Objetos(i).Contenedor = sNombre Then Objetos(i).Contenedor = "" End If Next ActualizarFormularios End Sub Private Sub cmdAceptar_Click() Unload Me End Sub Private Sub cmdBorrarUsr_Click() Dim i As Long, j As Long, k As Long, l As Long, n As Long Dim iOpc As Integer Dim sProp As String If Not HayPropUsrPSI Then Exit Sub End If For i = 0 To lblPropUsr.Count - 1 If lblPropUsr(i).Tag = "X" Then sProp = lblPropUsr(i).Caption iOpc = MsgBox("Se va a borrar la propiedad " & _ sProp & ". ¿Quieres continuar?", _ vbYesNo + vbQuestion, "Borrar propiedad de usuario") If iOpc = vbYes Then For j = NUM_PSIPROP_PREDEF To UBound(PSIProp) If UCase(PSIProp(j).Nombre) = sProp Then If j < UBound(PSIProp) Then For k = j To UBound(PSIProp) - 1 PSIProp(k) = PSIProp(k + 1) ' actualizamos la matriz de valores ' de propiedades del PSI If bHayPSI Then For l = 0 To UBound(PSIs) PSIs(l).PropUsr(k - NUM_PSIPROP_PREDEF) = PSIs(l).PropUsr(k - NUM_PSIPROP_PREDEF + 1) Next End If Next End If If UBound(PSIProp) < 1 Then ReDim PSIProp(0) Else ReDim Preserve PSIProp(UBound(PSIProp) - 1) End If ' actualizamos la matriz de valores ' de propiedades del PSI If bHayPSI Then n = UBound(PSIProp) - NUM_PSIPROP_PREDEF If n < 0 Then For l = 0 To UBound(PSIs) ReDim PSIs(l).PropUsr(0) Next Else For l = 0 To UBound(PSIs) ReDim Preserve PSIs(l).PropUsr(n) Next End If End If Exit For End If Next BarraScrollUsr PropiedadesUsuario ActualizarDatosPSI End If Exit Sub End If Next End Sub Private Sub cmdModificar_Click() Dim c As String, sNombre As String, sAdjetivo As String, sAntNombre As String, _ sNuevoNombre As String Dim i As Long, lPSI As Long Dim iOpc As Integer If lstPSIs.ListItems.Count < 1 Then Exit Sub End If ' coge número del PSI que está seleccionada c = lstPSIs.SelectedItem.key ' la clave tiene el formato Pnnn, donde 'nnn' es el número del PSI lPSI = CLng(Mid(c, 2)) If lPSI < 0 Then Exit Sub End If iOpc = MsgBox("Se va a modificar el nombre del PSI seleccionado." & _ " Este cambio puede afectar al código del programa." & _ " ¿Quieres continuar?", _ vbYesNo + vbQuestion, "AVISO") If iOpc <> vbYes Then Exit Sub End If ' recogemos el nuevo nombre sAntNombre = JuntaNombreAdj(PSIs(lPSI).Nombre, PSIs(lPSI).Adjetivo) c = InputBox("PSI", "Modificar nombre de PSI", sAntNombre) c = Trim(c) If c = "" Then Exit Sub End If ' separa nombre y adjetivo i = InStr(c, " ") If i = 0 Then sNombre = c sAdjetivo = "" Else ' comprobamos que no haya otro espacio If InStr(i + 1, c, " ") >= 1 Then MsgBox "El nombre del PSI no es válido.", vbOKOnly + vbExclamation, "Modificar nombre de PSI" Exit Sub End If sNombre = Left(c, i - 1) sAdjetivo = Mid(c, i + 1) End If sNombre = QuitaAcentos(Trim(UCase(sNombre))) sAdjetivo = QuitaAcentos(Trim(UCase(sAdjetivo))) ' comprobamos que el nombre no exista For i = 0 To UBound(PSIs) If i <> lPSI Then If PSIs(i).Nombre = sNombre And PSIs(i).Adjetivo = sAdjetivo Then MsgBox "El nombre está repetido.", vbOKOnly + vbExclamation, "Modificar nombre de PSI" Exit Sub End If End If Next ' cambiamos el nombre PSIs(lPSI).Nombre = sNombre PSIs(lPSI).Adjetivo = sAdjetivo lstPSIs.SelectedItem.SubItems(1) = sNombre lstPSIs.SelectedItem.SubItems(2) = sAdjetivo ' revisamos los objetos que tengan como contenedor este y los actualizamos sNuevoNombre = JuntaNombreAdj(sNombre, sAdjetivo) For i = 0 To UBound(Objetos) If Objetos(i).TipoContenedor = OBJ_CONTPSI And Objetos(i).Contenedor = sAntNombre Then Objetos(i).Contenedor = sNuevoNombre End If Next ActualizarFormularios End Sub Private Sub cmdNuevaUsr_Click() Dim c As String Dim i As Integer c = InputBox("Propiedad", "Añadir propiedad de usuario") c = Trim(c) If c = "" Then Exit Sub End If ' comprobamos si el nombre es válido c = UCase(c) If Not CompruebaNombreProcVar(c) Then MsgBox "El nombre de la propiedad no es válido.", vbOKOnly + vbCritical, "Añadir propiedad de usuario" Exit Sub End If ' comprobamos si ya existe For i = 0 To UBound(PSIProp) If UCase(PSIProp(i).Nombre) = c Or _ c = PSI_PROP_NOMBRE Or _ c = PSI_PROP_ADJETIVO Or _ c = PSI_PROP_DESCCORTA Or _ c = PSI_PROP_DESCLARGA Or _ c = PSI_PROP_LOCALIDAD Or _ c = PSI_PROP_PESO Or _ c = PSI_PROP_TAM Or _ c = PSI_PROP_GRAFICO Or _ c = PSI_PROP_SONIDO Or _ c = PSI_PROP_USUARIO Then MsgBox "El nombre de la propiedad está repetido.", vbOKOnly + vbCritical, "Añadir propiedad de usuario" Exit Sub End If Next ' añadimos If PSIProp(0).Nombre = "" Then i = 0 Else i = UBound(PSIProp) + 1 End If ReDim Preserve PSIProp(i) PSIProp(i).Tipo = TIPO_PROP_VAR PSIProp(i).Nombre = c i = lblPropUsr.Count If i = 1 And Not lblPropUsr(0).Visible Then lblPropUsr(0).Visible = True txtPropUsr(0).Visible = True cmdArray(0).Visible = True i = 0 Else Load lblPropUsr(i) Load txtPropUsr(i) Load cmdArray(i) lblPropUsr(i).Top = lblPropUsr(i - 1).Top + lblPropUsr(i - 1).Height txtPropUsr(i).Top = lblPropUsr(i).Top cmdArray(i).Top = lblPropUsr(i).Top lblPropUsr(i).Visible = True txtPropUsr(i).Visible = True cmdArray(i).Visible = True End If lblPropUsr(i).Caption = c txtPropUsr(i).Text = "" BloqueaArray i ' actualizamos la matriz de valores de propiedades ' de usuario en los PSIs If bHayPSI Then For i = 0 To UBound(PSIs) ReDim Preserve PSIs(i).PropUsr(UBound(PSIProp) - NUM_PSIPROP_PREDEF) Next End If BarraScrollUsr VScroll1.value = VScroll1.Max End Sub Private Sub cmdNuevo_Click() Dim Lst As ListItem Dim c As String, sNombre As String, sAdjetivo As String Dim n As Long GuardarDatosPSI c = InputBox("PSI", "Añadir PSI") c = Trim(c) If c = "" Then Exit Sub End If ' separa nombre y adjetivo n = InStr(c, " ") If n = 0 Then sNombre = c sAdjetivo = "" Else ' comprobamos que no haya otro espacio If InStr(n + 1, c, " ") >= 1 Then MsgBox "El nombre del PSI no es válido.", vbOKOnly + vbExclamation, "Añadir PSI" Exit Sub End If sNombre = Left(c, n - 1) sAdjetivo = Mid(c, n + 1) End If If Not NuevoPSI(sNombre, sAdjetivo, "", "", 0, 0, "", "") Then Exit Sub End If n = lstPSIs.ListItems.Count Set Lst = lstPSIs.ListItems.Add(, "P" & CStr(n), CStr(n)) Lst.SubItems(1) = PSIs(n).Nombre Lst.SubItems(2) = PSIs(n).Adjetivo ' selecciona el PSI que acabamos de añadir Set lstPSIs.SelectedItem = Lst ActualizarDatosPSI Lst.EnsureVisible ActualizarFormularios txtCorta.SetFocus End Sub Private Sub Form_Deactivate() GuardarDatosPSI End Sub Private Sub Form_Load() SSTab1.Tab = 0 BarraScrollUsr PropiedadesUsuario ActualizarProp ActualizarLoc ActualizarListaPSI End Sub Private Sub ActualizarProp() Dim i As Long lstProp.Clear On Error GoTo Err_Actualizar For i = 0 To NUM_PSIPROP_PREDEF - 1 lstProp.AddItem PSIProp(i).Nombre Next Err_Actualizar: Exit Sub End Sub Public Sub ActualizarLoc() Dim i As Long lstLoc.Clear If Not bHayLoc Then Exit Sub End If For i = 0 To UBound(Localidades) lstLoc.AddItem Localidades(i).Nombre Next End Sub Private Sub ActualizarListaPSI() Dim Lst As ListItem Dim i As Long lstPSIs.ListItems.Clear If Not bHayPSI Then Exit Sub End If For i = 0 To UBound(PSIs) Set Lst = lstPSIs.ListItems.Add(, "P" & CStr(i), CStr(i)) Lst.SubItems(1) = PSIs(i).Nombre Lst.SubItems(2) = PSIs(i).Adjetivo Next ActualizarDatosPSI End Sub Public Sub ActualizarDatosPSI() Dim c As String Dim i As Long, n As Long txtCorta.Text = "" txtLarga.Text = "" txtPeso.Text = "0" txtTam.Text = "0" lstLoc.Text = "" For i = 0 To lstProp.ListCount - 1 lstProp.Selected(i) = False Next If Not bHayPSI Then Exit Sub End If ' coge el PSI que está seleccionado If lstPSIs.ListItems.Count < 1 Then Exit Sub End If ' coge número del PSI que está seleccionado c = lstPSIs.SelectedItem.key ' la clave tiene el formato Pnnn, donde 'nnn' es el número del PSI i = CLng(Mid(c, 2)) If i < 0 Then Exit Sub End If txtCorta.Text = PSIs(i).DescCorta txtLarga.Text = PSIs(i).DescLarga txtPeso.Text = CStr(PSIs(i).Peso) txtTam.Text = CStr(PSIs(i).Tam) lstLoc.Text = PSIs(i).Localidad ' actualiza la lista de propiedades del PSI For n = 1 To Len(PSIs(i).Propiedades) c = Mid(PSIs(i).Propiedades, n, 1) lstProp.Selected(n - 1) = IIf(c = PROP_ACTIV, True, False) Next lstProp.Refresh ' propiedades de usuario ActualizarPropUsr PSIs(i) txtGrafico.Text = PSIs(i).Grafico txtSonido.Text = PSIs(i).Sonido End Sub ' guardamos los datos del PSI que estamos editando Public Sub GuardarDatosPSI() Dim c As String, sPSI As String, sAdjetivo As String Dim i As Long, j As Long, lNumProp As Long, lMaxProp As Long If Not bHayPSI Then Exit Sub End If ' coge el PSI que está seleccionado If lstPSIs.ListItems.Count < 1 Then Exit Sub End If sPSI = lstPSIs.SelectedItem.SubItems(1) sAdjetivo = lstPSIs.SelectedItem.SubItems(2) For i = 0 To UBound(PSIs) If PSIs(i).Nombre = sPSI And PSIs(i).Adjetivo = sAdjetivo Then On Error Resume Next PSIs(i).DescCorta = txtCorta.Text PSIs(i).DescLarga = txtLarga.Text ' controla errores de conversión PSIs(i).Peso = CLng(txtPeso.Text) If Err.Number <> 0 Then MsgBox "El peso del PSI debe ser numérico.", vbOKOnly + vbExclamation, "ERROR" Exit Sub End If PSIs(i).Tam = CLng(txtTam.Text) If Err.Number <> 0 Then MsgBox "El tamaño del PSI debe ser numérico.", vbOKOnly + vbExclamation, "ERROR" Exit Sub End If PSIs(i).Localidad = lstLoc.Text ' guarda el estado de las propiedades del PSI c = "" For j = 0 To lstProp.ListCount - 1 If lstProp.Selected(j) Then c = c & PROP_ACTIV Else c = c & PROP_DESACTIV End If Next PSIs(i).Propiedades = c ' propiedades de usuario If HayPropUsrPSI Then lNumProp = UBound(PSIProp) - NUM_PSIPROP_PREDEF If lNumProp < 0 Or PSIProp(0).Nombre = "" Then ReDim PSIs(i).PropUsr(0) Else If lNumProp > UBound(PSIs(i).PropUsr) Then ReDim Preserve PSIs(i).PropUsr(lNumProp) End If lMaxProp = VScroll1.value + MAX_PROP_USR - 1 If lMaxProp > lNumProp Then lMaxProp = lNumProp End If For j = VScroll1.value To lMaxProp PSIs(i).PropUsr(j) = txtPropUsr(j - VScroll1.value).Text Next End If End If PSIs(i).Grafico = txtGrafico.Text PSIs(i).Sonido = txtSonido.Text Exit Sub End If Next End Sub Private Sub Form_LostFocus() GuardarDatosPSI End Sub Private Sub Form_Unload(Cancel As Integer) GuardarDatosPSI End Sub Private Sub lstPSIs_ColumnClick(ByVal ColumnHeader As MSComctlLib.ColumnHeader) If ColumnHeader.index = 2 Then If lstPSIs.Sorted Then lstPSIs.Sorted = False ActualizarListaPSI Else lstPSIs.SortKey = 1 lstPSIs.Sorted = True End If End If End Sub Private Sub lstPSIs_ItemClick(ByVal Item As MSComctlLib.ListItem) ActualizarDatosPSI End Sub Private Sub lstPSIs_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) GuardarDatosPSI End Sub ' actualiza los formularios que dependen de este Private Sub ActualizarFormularios() If EstaCargado(frmObjetos) Then frmObjetos.ActualizarDatosObj End If If EstaCargado(frmLstPSI) Then frmLstPSI.ActualizarListaPSI End If End Sub Private Sub txtPropUsr_GotFocus(index As Integer) Dim i As Long For i = 0 To lblPropUsr.Count - 1 lblPropUsr(i).ForeColor = &H80000012 lblPropUsr(i).Tag = "" Next lblPropUsr(index).ForeColor = &HC0& lblPropUsr(index).Tag = "X" End Sub ' actualiza los valores de las propiedades de usuario Private Sub ActualizarPropUsr(P As Psi) Dim i As Long, lMaxProp As Long, lNumProp As Long If Not HayPropUsrPSI Then Exit Sub End If ' última propiedad a visualizar lMaxProp = VScroll1.value + MAX_PROP_USR - 1 lNumProp = UBound(PSIProp) - NUM_PSIPROP_PREDEF If lNumProp < 0 Then lNumProp = 0 End If If lMaxProp > lNumProp Then lMaxProp = lNumProp End If For i = VScroll1.value To lMaxProp txtPropUsr(i - VScroll1.value).Text = P.PropUsr(i) BloqueaArray i - VScroll1.value Next End Sub ' crea las 'casillas' para las propiedades de usuario Private Sub PropiedadesUsuario() Dim i As Long, lMaxProp As Long, lNumProp As Long Dim n As Integer ' primero borramos los controles que se hubiesen creado If lblPropUsr.Count > 1 Then For i = lblPropUsr.Count - 1 To 1 Step -1 Unload lblPropUsr(i) Unload txtPropUsr(i) Unload cmdArray(i) Next End If lblPropUsr(0).Visible = False txtPropUsr(0).Visible = False cmdArray(0).Visible = False ' si hay definidas propiedades de usuario If HayPropUsrPSI Then ' última propiedad a visualizar lMaxProp = VScroll1.value + MAX_PROP_USR - 1 lNumProp = UBound(PSIProp) - NUM_PSIPROP_PREDEF If lNumProp < 0 Then lNumProp = 0 End If If lMaxProp > lNumProp Then lMaxProp = lNumProp End If For i = VScroll1.value To lMaxProp If lblPropUsr(0).Visible Then n = lblPropUsr.Count Load lblPropUsr(n) Load txtPropUsr(n) Load cmdArray(n) lblPropUsr(n).Top = lblPropUsr(n - 1).Top + lblPropUsr(n - 1).Height txtPropUsr(n).Top = lblPropUsr(n).Top cmdArray(n).Top = lblPropUsr(n).Top lblPropUsr(n).Caption = PSIProp(i + NUM_PSIPROP_PREDEF).Nombre txtPropUsr(n).Text = "" BloqueaArray n lblPropUsr(n).Visible = True txtPropUsr(n).Visible = True cmdArray(n).Visible = True lblPropUsr(n).ForeColor = &H80000012 lblPropUsr(n).Tag = "" Else lblPropUsr(0).Caption = PSIProp(i + NUM_PSIPROP_PREDEF).Nombre txtPropUsr(0).Text = "" BloqueaArray 0 lblPropUsr(0).Visible = True txtPropUsr(0).Visible = True cmdArray(0).Visible = True lblPropUsr(0).ForeColor = &H80000012 lblPropUsr(0).Tag = "" End If Next End If End Sub ' ajusta la barra de scroll para las propiedades de usuario Private Sub BarraScrollUsr() Dim lNumProp As Long lNumProp = UBound(PSIProp) - NUM_PSIPROP_PREDEF + 1 If lNumProp < 0 Then lNumProp = 0 End If If lNumProp > MAX_PROP_USR Then VScroll1.Min = 0 VScroll1.Max = lNumProp - MAX_PROP_USR VScroll1.Enabled = True If VScroll1.value > VScroll1.Max Then VScroll1.value = VScroll1.Max End If Else VScroll1.Min = 0 VScroll1.Max = 0 VScroll1.value = 0 VScroll1.Enabled = False End If End Sub Private Sub txtPropUsr_Validate(index As Integer, Cancel As Boolean) GuardarDatosPSI Cancel = False End Sub Private Sub VScroll1_Change() PropiedadesUsuario ActualizarDatosPSI End Sub ' bloquea un campo de texto si contiene un array, lo desbloquea si no Private Sub BloqueaArray(i As Integer) If EsArray(txtPropUsr(i).Text) Then txtPropUsr(i).Locked = True txtPropUsr(i).BackColor = &HC0FFFF txtPropUsr(i).ForeColor = &HC0FFFF Else txtPropUsr(i).Locked = False txtPropUsr(i).BackColor = &H80000005 txtPropUsr(i).ForeColor = &H80000012 End If End Sub