SoloCodigo
Programación General => Visual Basic 6.0 e inferiores => Mensaje iniciado por: Miguel Angel Rodriguez en Domingo 5 de Octubre de 2003, 14:23
-
Hola amigos, estoy atascado con un problema que seguramente sea de lo mas chorra, pero llevo un par de dias jodido, el codigo es el siguiente:
Private Sub lblCajonCartas_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
'comprueba que haya carta
posy = lblCajonCartas(Index).Top
posx = lblCajonCartas(Index).Left
For i = 0 To 35
If lblCartas(i).Top = posy And lblCartas(i).Left = posx Then
'--segun el color elige el icono del arrastre
lblCartas(i).Drag 1
If i <= 5 Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "color(0).ico")
End If
If i > 5 And i <= 11 Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "color(6).ico")
End If
If i > 11 And i <= 17 Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "color(12).ico")
End If
If i > 17 And i <= 23 Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "color(18).ico")
End If
If i > 23 And i <= 29 Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "color(24).ico")
End If
If i > 29 And i <= 35 Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "color(30).ico")
End If
End If
Next i
End Sub
se trata de un juego de 36 cartas de seis colores diferentes; En un movimiento de arrastrar cartas, permitido al poner la propiedad drag =1, se sellecciona un icono diseñado previamente, cuyo nombre coincide exactamente con la variable color(i), pero evidentemente no carga un icono que se llame color(i), necesito algo que me devuelkva el valor de esa variable y lo ponga en la ruta para poderlo cargar.
Gracias:losiento:
-
Bueno perdonad si os he hecho perder el tiempo. Pero por fin lo he resuelto. He cambiado la forma de comparar y el resultado es el mismo. Os mando como ha quedado el código:
Private Sub lblCajonCartas_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
'comprueba que haya carta
posy = lblCajonCartas(Index).Top
posx = lblCajonCartas(Index).Left
For i = 0 To 35
If lblCartas(i).Top = posy And lblCartas(i).Left = posx Then
lblCartas(i).Drag 1
'--segun el color elige el icono del arrastre
If lblCartas(i).BackColor = QBColor(1) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "1.ico")
End If
If lblCartas(i).BackColor = QBColor(2) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "2.ico")
End If
If lblCartas(i).BackColor = QBColor(3) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "3.ico")
End If
If lblCartas(i).BackColor = QBColor(4) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "4.ico")
End If
If lblCartas(i).BackColor = QBColor(5) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "5.ico")
End If
If lblCartas(i).BackColor = QBColor(6) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "6.ico")
End If
If lblCartas(i).BackColor = QBColor(7) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "7.ico")
End If
If lblCartas(i).BackColor = QBColor(8) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "8.ico")
End If
If lblCartas(i).BackColor = QBColor(9) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "9.ico")
End If
If lblCartas(i).BackColor = QBColor(10) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "10.ico")
End If
If lblCartas(i).BackColor = QBColor(11) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "11.ico")
End If
If lblCartas(i).BackColor = QBColor(12) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "12.ico")
End If
If lblCartas(i).BackColor = QBColor(13) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "13.ico")
End If
If lblCartas(i).BackColor = QBColor(14) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "14.ico")
End If
If lblCartas(i).BackColor = QBColor(15) Then
lblCartas(i).DragIcon = LoadPicture(App.Path & "15.ico")
End If
End If
Next i
End Sub
Personalmente me gutaba más antes, pero los que estamos limitados, no podemos ser brillantes.
Saludos, y tema zanjado.:hola::good:
-
Hola colega creo ke lo ke estas haciendo mal es la linea ...
-----------lblCartas(i).DragIcon = LoadPicture(App.Path & "color(0).ico")----
La propiedad .LoadPicture debe contener una ruta terminada en un nombre de archivo .ico (en tu caso) Para devolver el numero ke buscas ...
de forma ke no puedes poner entre comillas el ...
"color(i).Ico" puesto ke kedaria:
Load Picture(C:Mi Programacolor(i).ico)
No encontrando la ruta de acceso al icono ke deseas, Ok?
Por tanto debes poner la linea como:
lblCartas(i).DragIcon = LoadPicture(App.Path & "" & Cstr(color(i)) & ".ico")
Asi nos keda ...
LoadPicture(C:Mi ProgramaAzul.ico) devolviendo el numero a la propiedad .DragIcon, donde la variable
color(i)=Azul
Espero sea esta tu duda, Fale? Un saludo
:hippi: