Yuval ayudaaaaaaaaaaaaaa!! de hoy no paso
como veo que mis explicaciones no son una maravilla aqui te envio el codigo a ver que te parece:
Private Sub cmdarriba_Click()
a = lst1.ListIndex
If lst1.ListIndex = 0 Then
MsgBox ("principio")
Else
lst1.ListIndex = (a - 1) 'me sale fallo aqui'
End If
End Sub
Private Sub cmdabajo_Click()
a = lst1.ListIndex
If lst1.ListIndex = (lst.ListCount - 1) Then
MsgBox ("ultimo")
Else
lst1.ListIndex = (a + 1)
End If
End Sub
Private Sub Command1_Click()
FIN
Unload Me
End Sub
Private Sub Form_Load()
INI
Dim a As Variant
End Sub
" Claro aqui falta lo del módulo(que es de las apis) pero no creo que sea necesario que te lo mande, espero que puedas ayudarme.
Gracias( al final me voy a hacer famoso en este foro).
Private Sub cmdarriba_Click()
a = lst1.ListIndex
If lst1.ListIndex = 0 Then
MsgBox ("principio")
Else
lst1.ListIndex = (a - 1) 'me sale fallo aqui'
End If
End Sub
Private Sub cmdabajo_Click()
a = lst1.ListIndex
If lst1.ListIndex = (lst.ListCount - 1) Then
MsgBox ("ultimo")
Else
lst1.ListIndex = (a + 1)
End If
End Sub
Private Sub Command1_Click()
FIN
Unload Me
End Sub
Private Sub Form_Load()
INI
Dim a As Variant
End Sub
" Claro aqui falta lo del módulo(que es de las apis) pero no creo que sea necesario que te lo mande, espero que puedas ayudarme.
Gracias( al final me voy a hacer famoso en este foro).
hola, eso sucede porque seguro que ListIndex es igual a -1, que és cuando no hay ningún elemento seleccionado. sólo tienes que poner que sea <= que.
Private Sub cmdarriba_Click()
a = lst1.ListIndex
If lst1.ListIndex <= 0 Then <----- si és menor que uno
MsgBox ("principio")
Else
lst1.ListIndex = (a - 1) 'me sale fallo aqui'
End If
o si quieres puedes añadir:
If lst1.ListIndex = -1 Then
Msgbox "Ningún elemento seleccionado"
'o en lugar de esto
lst1.ListIndex = 0
Exit Sub
End If
según tu intención.
saludos.
Private Sub cmdarriba_Click()
a = lst1.ListIndex
If lst1.ListIndex <= 0 Then <----- si és menor que uno
MsgBox ("principio")
Else
lst1.ListIndex = (a - 1) 'me sale fallo aqui'
End If
o si quieres puedes añadir:
If lst1.ListIndex = -1 Then
Msgbox "Ningún elemento seleccionado"
'o en lugar de esto
lst1.ListIndex = 0
Exit Sub
End If
según tu intención.
saludos.
Private Sub command1_Click()
a = Lst1.ListIndex
If Lst1.ListIndex <= 0 Then
MsgBox ("principio")
Else
Lst1.ListIndex = (a - 1)
End If
End Sub
Private Sub command2_Click()
a = Lst1.ListIndex
b = Lst1.ListCount
If Lst1.ListIndex = (b - 1) Then
MsgBox ("ultimo")
Else
Lst1.ListIndex = (a + 1)
End If
End Sub
Private Sub Form_Load()
Lst1.ListIndex = 0
End Sub
a = Lst1.ListIndex
If Lst1.ListIndex <= 0 Then
MsgBox ("principio")
Else
Lst1.ListIndex = (a - 1)
End If
End Sub
Private Sub command2_Click()
a = Lst1.ListIndex
b = Lst1.ListCount
If Lst1.ListIndex = (b - 1) Then
MsgBox ("ultimo")
Else
Lst1.ListIndex = (a + 1)
End If
End Sub
Private Sub Form_Load()
Lst1.ListIndex = 0
End Sub