|
Mostrar Mensajes
|
Páginas: [1]
|
2
|
Programación / Programación Visual Basic / Re: Problema con el Sorted
|
en: 10 Enero 2017, 12:20 pm
|
Vale creo que he dado en un punto clave, el list1 depende directamente del campo/función SEtiquetaTxt y PlantillasLST (que tambien es un listbox que esta bajo el cuadrito de Listbox1) . Tal y como lo entiendo el texto de List1 viene de el PlantillaLST y este a su vez, de SEtiquetaTxt.. ¿puede tener algo que ver o estoy dando palos de ciego?
|
|
|
3
|
Programación / Programación Visual Basic / Re: Problema con el Sorted
|
en: 10 Enero 2017, 10:09 am
|
No me los ordena para nada, arriba tienes el código del formulario que trabaja con el listbox. Hay otro formulario pero no tiene relevancia para este listbox (no aparece de ninguna manera en ese formulario). Lo único que se me ocurre es que tenga que hacerse algo en el módulo de funciones que si aparece el listbox, pero no tengo muy claro lo que hace. Os pego el código y subrayo (esta casi al final) la parte del código que pueda ser relevante. La pregunta es: esta claro que por lo que sea el sorted no funciona, ¿no hay manera de intentar ordenar el listbox de alguna otra manera?. Graciñas. Public Contador As Integer, Comproba As String, Bucle As Long, Intro As String Public Letra As String, UltimoValor As String, Ficheiro2 Public TextoFixoAplicador As String, NLiñas As String Public Function CargarOFs() Dim Tamaño As Integer, ManexoSistema, ManexoFicheiros, Un Call ReiniciarLSTs Tamaño = Len(ConfigFRM.ConfigTXT(0).Text): Contador = 0 On Error Resume Next Set ManexoSistema = CreateObject("Scripting.FileSystemObject") On Error Resume Next Set ManexoFicheiros = ManexoSistema.GetFolder(ConfigFRM.ConfigTXT(0).Text) For Each Un In ManexoFicheiros.Files Un = Right(Un, Len(Un) - Tamaño) If Right(Un, 3) = ".ok" Or Right(Un, 3) = ".OK" Or Right(Un, 3) = ".Ok" Or Right(Un, 3) = ".oK" Then Un = Left(Un, Len(Un) - 3) PrincipalFRM.FicheirosLST.List(Contador) = Un Contador = Contador + 1 End If Next End Function
Public Function CargarFicheiro(Tipo As String, Ficheiro As String) Contador = 0 Comproba = Dir(Ficheiro) Select Case Comproba Case "" Case Else Open Ficheiro For Input Access Read As #1 Do While Not EOF(1) Letra = Input(1, #1) Select Case Letra Case Chr(13): Contador = Contador + 1 Case Chr(10) Case Else: Select Case Tipo Case "Config": ConfigFRM.ConfigTXT(Contador).Text = ConfigFRM.ConfigTXT(Contador).Text & Letra End Select End Select Loop Close #1 End Select End Function
Public Function GardarConfig() Dim Configurar As String For Bucle = 0 To (ConfigFRM.ConfigTXT.Count - 1) Configurar = Configurar & ConfigFRM.ConfigTXT(Bucle).Text & Intro Next Bucle Open App.Path & "\config.cfg" For Output Access Write As #1 Print #1, Configurar Close #1 End Function
Public Function LeerOFs() For Bucle = 0 To (PrincipalFRM.FicheirosLST.ListCount - 1) Contador = 0 Open ConfigFRM.ConfigTXT(0).Text & PrincipalFRM.FicheirosLST.List(Bucle) & ".ok" For Input Access Read As #1 Do While Not EOF(1) Letra = Input(1, #1) Select Case Letra Case Chr(13) Case Chr(10) Case "|": Contador = Contador + 1 Case Else Select Case Contador Case 0: PrincipalFRM.CodigoLST.List(Bucle) = PrincipalFRM.CodigoLST.List(Bucle) & Letra Case 1: PrincipalFRM.DescripcionLST.List(Bucle) = PrincipalFRM.DescripcionLST.List(Bucle) & Letra Case 2: PrincipalFRM.LoteLST.List(Bucle) = PrincipalFRM.LoteLST.List(Bucle) & Letra Case 3: PrincipalFRM.PesoLST.List(Bucle) = PrincipalFRM.PesoLST.List(Bucle) & Letra Case 4: PrincipalFRM.LineaLST.List(Bucle) = PrincipalFRM.LineaLST.List(Bucle) & Letra Case 5: PrincipalFRM.SacoLST.List(Bucle) = PrincipalFRM.SacoLST.List(Bucle) & Letra Case 6: PrincipalFRM.SeriesLST.List(Bucle) = PrincipalFRM.SeriesLST.List(Bucle) & Letra Case 7: PrincipalFRM.OFsLST.List(Bucle) = PrincipalFRM.OFsLST.List(Bucle) & Letra Case 8: On Error Resume Next PrincipalFRM.CantLST.List(Bucle) = PrincipalFRM.CantLST.List(Bucle) & Letra Case 9: On Error Resume Next PrincipalFRM.EnvaseLST.List(Bucle) = PrincipalFRM.EnvaseLST.List(Bucle) & Letra Case 10: On Error Resume Next PrincipalFRM.GranelLST.List(Bucle) = PrincipalFRM.GranelLST.List(Bucle) & Letra End Select End Select Loop Close #1 Next Bucle End Function
Public Function ReiniciarLSTs() PrincipalFRM.LineaLST.Clear PrincipalFRM.LoteLST.Clear PrincipalFRM.CodigoLST.Clear PrincipalFRM.OFsLST.Clear PrincipalFRM.DescripcionLST.Clear PrincipalFRM.FicheirosLST.Clear PrincipalFRM.PesoLST.Clear PrincipalFRM.SacoLST.Clear PrincipalFRM.SeriesLST.Clear On Error Resume Next PrincipalFRM.GranelLST.Clear On Error Resume Next PrincipalFRM.EnvaseLST.Clear On Error Resume Next PrincipalFRM.CantLST.Clear End Function
Public Function PasarValor(Numero As Integer) With PrincipalFRM .SLineaTXT.Text = .LineaLST.List(Numero) .SLoteTXT.Text = .LoteLST.List(Numero) .ScodigoTXT.Text = .CodigoLST.List(Numero) .SOFsTXT.Text = .OFsLST.List(Numero) .SDescripcionTXT.Text = .DescripcionLST.List(Numero) .SPesoTXT.Text = .PesoLST.List(Numero) .SSacoTXT.Text = .SacoLST.List(Numero) .SSeriesTXT.Text = .SeriesLST.List(Numero) On Error Resume Next .SCantidadeTXT.Text = .CantLST.List(Numero) On Error Resume Next .SenvaseTXT.Text = .EnvaseLST.List(Numero) On Error Resume Next .SGranelTXT.Text = .GranelLST.List(Numero) End With End Function
Public Function AxustarLSTs(Numero As Integer) With PrincipalFRM .FicheirosLST.Selected(Numero) = True .LineaLST.Selected(Numero) = True .LoteLST.Selected(Numero) = True .CodigoLST.Selected(Numero) = True .OFsLST.Selected(Numero) = True .DescripcionLST.Selected(Numero) = True .PesoLST.Selected(Numero) = True .SacoLST.Selected(Numero) = True .SeriesLST.Selected(Numero) = True On Error Resume Next .CantLST.Selected(Numero) = True On Error Resume Next .EnvaseLST.Selected(Numero) = True On Error Resume Next .GranelLST.Selected(Numero) = True End With End Function
Public Function BorrarSeleccions() Dim Boclo As Integer With PrincipalFRM For Boclo = 0 To (.FicheirosLST.ListCount - 1) .FicheirosLST.Selected(Boclo) = False .LineaLST.Selected(Boclo) = False .LoteLST.Selected(Boclo) = False .CodigoLST.Selected(Boclo) = False .OFsLST.Selected(Boclo) = False .DescripcionLST.Selected(Boclo) = False .PesoLST.Selected(Boclo) = False .SacoLST.Selected(Boclo) = False .SeriesLST.Selected(Boclo) = False On Error Resume Next .CantLST.Selected(Boclo) = False On Error Resume Next .EnvaseLST.Selected(Boclo) = False On Error Resume Next .GranelLST.Selected(Boclo) = False Next Boclo End With End Function Public Function ReiniciarEnvio() With PrincipalFRM .SLineaTXT.Text = "" .SLoteTXT.Text = "" .ScodigoTXT.Text = "" .SOFsTXT.Text = "" .SDescripcionTXT.Text = "" .SPesoTXT.Text = "" .SSacoTXT.Text = "" .SSeriesTXT.Text = "" On Error Resume Next .SCantidadeTXT.Text = "" On Error Resume Next .SenvaseTXT.Text = "" On Error Resume Next .SGranelTXT.Text = "" End With End Function
Public Function LeerPlantillas() Dim Tamaño As Integer, ManexoSistema, ManexoFicheiros, Un Tamaño = Len(ConfigFRM.ConfigTXT(2).Text): Contador = 0 Set ManexoSistema = CreateObject("Scripting.FileSystemObject") On Error Resume Next Set ManexoFicheiros = ManexoSistema.GetFolder(ConfigFRM.ConfigTXT(2).Text) If Err.Number <> 0 Then MsgBox ("Erro grave de configuración leendo as plantillas") Err.Clear Exit Function End If [b][u]For Each Un In ManexoFicheiros.Files Un = Right(Un, Len(Un) - Tamaño) If Right(Un, 4) = ".lbe" Or Right(Un, 4) = ".LBE" Or Right(Un, 4) = ".Lbe" Or Right(Un, 4) = ".lbE" Then Un = Left(Un, Len(Un) - 4) PrincipalFRM.PlantillasLST.List(Contador) = Un PrincipalFRM.List1.List(Contador) = Un Contador = Contador + 1 End If[/u][/b] Next End Function
Public Function BorrarFicheiro(NomeFicheiro As String) Ficheiro2 = ConfigFRM.ConfigTXT(0).Text & NomeFicheiro & ".ok" Comproba = Dir(Ficheiro2) Select Case Comproba Case "" MsgBox ("Non se puido borrar o ficheiro da orde de fabricación") Case Else Kill Ficheiro2 End Select Call CargarOFs Call LeerOFs Call ReiniciarEnvio End Function
Public Function EnviarOF(NomeOF As String, Contido As String) Ficheiro = ConfigFRM.ConfigTXT(1).Text & NomeOF & ".ord" Open Ficheiro For Output Access Write As #1 Print #1, Contido Close #1 Call BorrarFicheiro(NomeOF) Call ReiniciarLSTs Call CargarOFs Call LeerOFs End Function
|
|
|
4
|
Programación / Programación Visual Basic / Re: Problema con el Sorted
|
en: 10 Enero 2017, 09:01 am
|
Vale, a ver uso, AddItem. Lo que he hecho es: If Left(PlantillasLST.List(Bucle), tomoño) = BuscaTXT.Text Then 'List1.List(conto) = PlantillasLST.List(Bucle) 'conto = conto + 1 List1.AddItem (PlantillasLST.List(Bucle)) End If Y poner Sorted = True en el List1 y para el PlantillasLST.List Pero sigue sin ir!! no sé que pasa!! alguna idea?¿ Los valores que quiero que ordene el Listbox son nombres de peces alfabéticamente.. Para que os hagais una idea, os pongo una captura: el listbox va enlazado a otros campos..¿puede ser esta la razón de que no lo ordene?.. no se muy bien que hacer.. Gracias por vuestras ayudas y comentarios.
|
|
|
5
|
Programación / Programación Visual Basic / Re: Problema con el Sorted
|
en: 9 Enero 2017, 11:21 am
|
Um.. Gracias de nuevo. Voy a probar a ver. En principio solo quiero que el List1 me muestre los resultados alfabéticamente y YA. He puesto tambien el Sorted de PlantillasLST en True tambien. Con poner lo de AddItem, ¿dices que ya valdría? ¿no haría falta definir el True en el código? ¿solo con ponerlo en la opciones como True ya vale?. Muchas gracias, me estais ayudando mucho.
|
|
|
6
|
Programación / Programación Visual Basic / Re: Problema con el Sorted
|
en: 9 Enero 2017, 09:48 am
|
A ver pongo el List1.Sorted = True al principio del código, despues de definir variables y cuando doy a compilar me sale "error de compilacion no se puede asignar a propiedad de solo lectura".. pero si lo cambio a Listbox.Sorted = True no me da dicho error y si que me deja compilar, pero no sé si me funciona o no.. ¿A que se debe esto? ¿Es por que hay que definir el objeto como propiedad general o como?. Gracias de nuevo.
|
|
|
7
|
Programación / Programación Visual Basic / Re: Problema con el Sorted
|
en: 9 Enero 2017, 08:49 am
|
Buenos dias, muchas gracias por contestar. Agradezco mucho las aclaraciones, en realidad solo quiero que el listbox me muestre el contenido ALFABÉTICAMENTE... en ese caso tendría con poner el sorted en sitio adecuado, ¿valdría?.. En cualquier caso me apunto lo de los numeros pues seguramente me sea últil en el futuro...
|
|
|
8
|
Programación / Programación Visual Basic / Problema con el Sorted
|
en: 5 Enero 2017, 13:15 pm
|
Buenas. Tengo una aplicación (no creada por mi) en la cual, uno de los ListBox ha de mostrarse por orden alfabético.. Sé que la opción más fácil es la de modificar la propiedad Sorted para el Listbox. El tema es que haga lo que haga, no funciona. Os pego un par de pantallazos para que veias el tema : Como veis, he probado a cambiarlo en cuadro de propiedades y tambien en el código pero nada. Decir que tengo (más bien tenía, pero siempre a nivel bastante básico) algo de conocimientos de Vb pero hace muchísimo que no lo toco y ahora acabo de entrar en una nueva empresa y las estoy pasando algo canutas. Asi que, por favor si pudierais echarme una mano os lo agradecería inmensamente. Por si fuera de ayuda, tambien os pego el código del formulario principal. Private Sub BuscaTXT_Change() Dim tomoño As String, conto As Integer List1.Clear tomoño = Len(BuscaTXT.Text) 'If tomoño <> "" Then For Bucle = 0 To (PlantillasLST.ListCount - 1) If Left(PlantillasLST.List(Bucle), tomoño) = BuscaTXT.Text Then List1.List(conto) = PlantillasLST.List(Bucle) conto = conto + 1 End If Next Bucle 'Else 'For Bucle = 0 To (PlantillasLST.ListCount - 1) ' List1.List(Bucle) = PlantillasLST.List(Bucle) 'Next Bucle 'End If End Sub
Private Sub CodigoLST_Click() Call AxustarLSTs(CodigoLST.ListIndex) Call PasarValor(CodigoLST.ListIndex) End Sub
Private Sub ControlTMP_Timer() Estado = True If SOFsTXT.Text = "" Then Estado = False If SEtiquetaTXT.Text = "" Then Estado = False If Estado = True Then FuncionCMD(1).Enabled = True Else FuncionCMD(1).Enabled = False End Sub
Private Sub DescripcionLST_Click() Call AxustarLSTs(DescripcionLST.ListIndex) Call PasarValor(DescripcionLST.ListIndex) End Sub
Private Sub FicheirosLST_Click() Call AxustarLSTs(FicheirosLST.ListIndex) Call PasarValor(FicheirosLST.ListIndex) End Sub
Private Sub Form_Load() Intro = Chr(13) & Chr(10) Call CargarFicheiro("Config", App.Path & "\config.cfg") Call CargarOFs Call LeerOFs Call LeerPlantillas Seguro = False End Sub
Private Sub Form_Unload(Cancel As Integer) End End Sub
Private Sub FuncionCMD_Click(Index As Integer) Select Case Index Case 0: Call CargarOFs Call LeerOFs Case 1: Call EnviarOF(SSeriesTXT.Text & SOFsTXT.Text, SSeriesTXT.Text & Intro & SOFsTXT.Text & Intro & SDescripcionTXT.Text & Intro & SLoteTXT.Text & Intro & SPesoTXT.Text & Intro & ScodigoTXT.Text & Intro & SSacoTXT.Text & Intro & SLineaTXT.Text & Intro & SEtiquetaTXT.Text & Intro & SCantidadeTXT.Text & Intro & SenvaseTXT.Text & Intro & SGranelTXT.Text & Intro) Case 2: If FicheirosLST.ListIndex <> -1 Then Call BorrarFicheiro(FicheirosLST.List(FicheirosLST.ListIndex)) End If Case 3: Call LeerPlantillas Case 4: SEtiquetaTXT.Text = "-": SSacoTXT.Text = "N" 'Case 5: 'Call EnviarOF(Right("0" & Second(Time), 2) & Right("000000" & Minute(Time), 6), Right("0" & Second(Time), 2) & Intro & Right("000000" & Minute(Time), 6) & Intro & "PEIXE FRESCO" & Intro & "L4632" & Intro & "40KG" & Intro & "45687" & Intro & "S" & Intro & "1" & Intro & SEtiquetaTXT.Text & Intro) End Select End Sub
Private Sub LineaLST_Click() Call AxustarLSTs(LineaLST.ListIndex) Call PasarValor(LineaLST.ListIndex) End Sub
Private Sub List1_Click() SEtiquetaTXT.Text = List1.Text List1.Sorted = True End Sub
Private Sub LoteLST_Click() Call AxustarLSTs(LoteLST.ListIndex) Call PasarValor(LoteLST.ListIndex) End Sub
Private Sub MNUConfigurar_Click() ConfigFRM.Visible = True End Sub
Private Sub MNUPechar_Click() End End Sub
Private Sub OFsLST_Click() Call AxustarLSTs(OFsLST.ListIndex) Call PasarValor(OFsLST.ListIndex) End Sub
Private Sub PesoLST_Click() Call AxustarLSTs(PesoLST.ListIndex) Call PasarValor(PesoLST.ListIndex) End Sub
Private Sub PlantillasLST_Click() SEtiquetaTXT.Text = PlantillasLST.Text SSacoTXT.Text = "S" End Sub
Private Sub SacoLST_Click() Call AxustarLSTs(SacoLST.ListIndex) Call PasarValor(SacoLST.ListIndex) End Sub
Private Sub SeriesLST_Click() Call AxustarLSTs(SeriesLST.ListIndex) Call PasarValor(SeriesLST.ListIndex) End Sub
Muchas gracias y perdonad si la pregunta es muy tonta pero estoy bastante ofuscado. Graciñas de nuevo.
|
|
|
|
|
|
|