Programación General > Visual Basic 6.0 e inferiores

 Mostrar Los Top 10 Con Objeto Label(0)

(1/1)

Bluebird:
Holas.... :rolleyes:

Estoy intentando que a partir de una consulta de una base de datos access pueda mostrar en una pantallita la lista de los 10 temas mas escuchados...creo que no la estoy pegando en la matriz label(0).

El código es el que sigue:


--- Código: Text --- Option ExplicitOption Base 1Dim Tapa As IntegerDim creditos As IntegerDim Pasa_Pago As Boolean ' Carga las tapas de los albunes Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)On Error GoTo err    cargaTemas Adodc1.Recordset!nalbum    If Dir("c:\mp3\imagenes\" & Adodc1.Recordset!nalbum & ".jpg") <> "" Then        PicTapa.Picture = LoadPicture("c:\mp3\imagenes\" & Adodc1.Recordset!nalbum & ".jpg")    Else        PicTapa.Picture = LoadPicture("c:\mp3\imagenes\noimage.jpg")            End Iferr:End Sub Private Sub cmdAdelante_Click()If Adodc1.Recordset.Bookmark <> Adodc1.Recordset.RecordCount Then    Adodc1.Recordset.MoveNext    End IfEnd Sub Private Sub cmdAtras_Click()If Adodc1.Recordset.Bookmark > 1 Then    Adodc1.Recordset.MovePrevious    End IfEnd Sub Private Sub cmdCreditos_Click()End Sub Private Sub Form_KeyPress(keyascii As Integer)Dim nT As IntegerDim R As IntegerSelect Case keyascii   Case Asc("0")        If List3.ListCount > 0 Then        Pasa_Pago = True        Mp1.Stop        Mp1.Open "c:\mp3\" & List3.ItemData(0) & ".mp3"        Mp1.Volume = -10        Graba_tema List3.ItemData(0)        List3.RemoveItem (0)    Else        Pasa_Pago = False        RandTema    End If     Case Asc("6")        cmdAdelante_Click    Case Asc("4")        cmdAtras_Click    Case Asc("2")        If List1.ListCount - 1 <> List1.ListIndex Then            List1.ListIndex = List1.ListIndex + 1        End If    Case Asc("8")        If List1.ListIndex > 0 Then            List1.ListIndex = List1.ListIndex - 1        End If    Case Asc("5")    [COLOR=red]        If creditos = 0 Then            frametop10.Visible = Truecargaadodc Adodc1, "SELECT TOP 10 Tema, Autor, NúmeroDeDuplicados FROM Reproducidos ORDER BY NúmeroDeDuplicados DESC;"                For R = 0 To 9                        Label10(R).DataField = “”                        Label11(R).DataField = “”                Next R            End If[/COLOR]                If List1.ListIndex <> -1 Then            If creditos > 0 Then                List2.AddItem Label3(0).Caption & " - " & List1.Text                List2.ItemData(List2.NewIndex) = List1.ItemData(List1.ListIndex)                creditos = creditos - 1                Label1.Caption = creditos            End If                If List2.ListCount > 0 Then                    ''''frmMP3Play.Show ''1                    For nT = 0 To List2.ListCount - 1                        List3.AddItem List2.List(nT)                        List3.ItemData(List3.NewIndex) = List2.ItemData(nT)                    Next                        List2.Clear                        Pasa_Tema                End If        End If                Case Asc("9") '''moneda            frametop10.Visible = False            creditos = creditos + TemXcre            Label1.Caption = creditos    Case Asc("7")        If InputBox("Cierra") = "77" Then ShutdownSystem EWX_POWEROFF      Case vbKeyEscape        EndEnd SelectEnd Sub Private Sub Form_Load()frametop10.Visible = FalsePasa_Pago = Falsecargaadodc Adodc1, "SELECT Albumes.ID_Album as nalbum, Albumes.Album, Albumes.id_autor, Albumes.Genero, Autores.Autor FROM Autores INNER JOIN Albumes ON Autores.ID_Autor = Albumes.id_autor ORDER BY Genero,Autores.Autor;"   'Load Form2    WndShow1.WindowHandle = frmSeleccionTemas.hWnd    WndShow1.Showcreditos = 0Label1.Caption = creditosLabel7.Caption = IIf(TemXcre = 1, "1 Moneda = 1 Tema/s", "1 Moneda = " & TemXcre & " Temas/s")Mp2.FileName = App.Path & "\vidfon.wmv"Me.Width = Screen.WidthMe.Height = Screen.HeightEnd Sub Private Sub Mp1_EndOfStream(ByVal Result As Long)pasa_siguienteEnd Sub ' Carga temas Albunes Private Function cargaTemas(ndisco)Dim Reco As ADODB.RecordsetDim nvSet Reco = New ADODB.RecordsetReco.Open "select * from temas where id_album = " & ndisco & " order by id_tema", Constri, adOpenStatic, adLockReadOnlynv = 1If Reco.RecordCount <> 0 ThenList1.Clear    Do While Not Reco.EOF        List1.AddItem Format$(nv, "00") & " - " & Reco!Tema        List1.ItemData(List1.NewIndex) = Reco!Id_Tema        nv = nv + 1    Reco.MoveNext    LoopEnd IfReco.CloseEnd Function Private Sub Pasa_Tema() If Pasa_Pago = False Then    If List3.ListCount > 0 Then       ' Mp3.Command = "Stop"        Pasa_Pago = True        Mp1.Stop        Mp1.Open "c:\mp3\" & List3.ItemData(0) & ".mp3"        Mp1.Volume = -50        Graba_tema List3.ItemData(0)        List3.RemoveItem (0)    Else        Pasa_Pago = False        RandTema    End IfEnd If End SubPrivate Sub pasa_siguiente()Label8(0).Caption = ""Label8(1).Caption = ""        If List3.ListCount > 0 Then        Pasa_Pago = True        Mp1.Stop        Mp1.Open "c:\mp3\" & List3.ItemData(0) & ".mp3"        Mp1.Volume = -10        Graba_tema List3.ItemData(0)        List3.RemoveItem (0)    Else        Pasa_Pago = False        RandTema    End If End SubPrivate Sub RandTema()Dim rec1 As ADODB.RecordsetDim Ntemas As IntegerDim nroTem As IntegerDim rnLabel8(0).Caption = ""Label8(1).Caption = ""'Label8(2).Caption = "" Pasa_Pago = FalseSet rec1 = New ADODB.Recordsetrec1.Open "select * from temas", Constri, adOpenStatic, adLockReadOnlyNtemas = rec1.RecordCountRandomizern = Int((Ntemas * Rnd))   ' Genera valores aleatorios entre 1 y 6.'rn = Int(Ntemas / 60 * Second(Time))rec1.MoveFirstrec1.Move rnnroTem = rec1(0)rec1.CloseSet rec1 = NothingMp1.StopTMRTema.Enabled = TrueMp1.Volume = -2700Mp1.Open "c:\mp3\" & nroTem & ".mp3" End Sub Private Sub tmrPasa_Timer()tmrPasa.Enabled = Falsepasa_siguienteEnd Sub Private Function Graba_tema(nTem As Integer)Dim con As ADODB.ConnectionDim rec1 As ADODB.RecordsetSet con = New ADODB.ConnectionSet rec1 = New ADODB.Recordsetrec1.Open "SELECT Temas.Tema, Autores.Autor FROM Autores INNER JOIN (Albumes INNER JOIN Temas ON Albumes.ID_Album = Temas.Id_album) ON Autores.ID_Autor = Albumes.id_autor WHERE (((Temas.Id_Tema)=" & nTem & "));", Constri, adOpenStatic, adLockReadOnly    If rec1.RecordCount <> 0 Then        Label8(0).Caption = rec1(0)        Label8(0).Refresh        Label8(1).Caption = rec1(1)        Label8(1).Refresh                    End If rec1.Closecon.Open Constricon.Execute "insert into reproducciones (id_tema) values (" & nTem & ")"con.CloseSet con = NothingEnd Function Private Sub TMRTema_Timer()Label4.Caption = Mp1.CurrentPositionIf Pasa_Pago = False Then    If Mp1.CurrentPosition > 40 Then        Mp1.Stop        pasa_siguiente      '  TMRTema.Enabled = False    End IfEnd IfEnd Sub   

En el sector marcado en rojo es donde quiero que se ejecute...
Gracias y saludos :hola:

solcito:
Mira no leí tu código porq la verdad no tengo ganas :P

Pero si quieres mostrar registros de una base lo mejor en una datagrid o msflexgrid u ListBox, cualquier cosa menos labels :S

Saludos :hola:

Bluebird:
Solcito:

Si no quieres ver el código completo fijate solo en la sección "Case "5""...¿me recomiendas mejor esos otros métodos ?...

Gracias :hola:

Navegación

[0] Índice de Mensajes

Ir a la versión completa