Dragdrop En Visual Basic

5

Transcript of Dragdrop En Visual Basic

Page 1: Dragdrop En Visual Basic
Page 2: Dragdrop En Visual Basic

• En visual podemos hacer un DragDrop “juego de arrastrar“, este juego • es muy útil para nuestro MEC "ingles básico" porque es muy educativo.• para este juego utilizaremos en el cuadro de herramientas:

• Label: estos son cuadros rectangulares• Image: esta herramienta en visual es cuadrada y sirve para llamar imágenes al juego

• Los Label los utilizamos para escribir los títulos correspondientes a cada imagen • Los image son las imágenes que arrastramos al label

• Los Label le ponemos un nombre como Label5, esto influye en la codificación• Los image les ponemos un nombre ej: Image6, porque esto influye en la codificación

Page 3: Dragdrop En Visual Basic

• Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)• Source.Move (X - Source.Width / 2), (Y - Source.Height / 2)• End Sub

• Private Sub Image1_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image9 Then• Image1.Picture = Image9.Picture• Image9.Visible = False• Label1.Caption = "¡Correcto!"• Beep• Else• Label1.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

• Private Sub Image2_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image15 Then• Image2.Picture = Image15.Picture• Image15.Visible = False• Label6.Caption = "¡Correcto!"• Beep• Else• Label6.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

Page 4: Dragdrop En Visual Basic

• Private Sub Image3_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image11.Visible = False Then• Image3.Picture = Image11.Picture• Image11.Visible = False• Label9.Caption = "¡Correcto!"• Beep• Else• Label9.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

• Private Sub Image4_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image10 And Image12.Visible = False Then• Image4.Picture = Image10.Picture• Image10.Visible = False• Label7.Caption = "¡Correcto!"• Beep• Else• Label7.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

• Private Sub Image5_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image14 Then• Image5.Picture = Image14.Picture• Image14.Visible = False• Label3.Caption = "¡Correcto!"• Beep• Else• Label3.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

• Private Sub Image6_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image12 Then• Image6.Picture = Image12.Picture• Image12.Visible = False• Label8.Caption = "¡Correcto!"• Beep• Else• Label8.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

Page 5: Dragdrop En Visual Basic

• Private Sub Image7_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image16 Then• Image7.Picture = Image16.Picture• Image16.Visible = False• Image7.ZOrder 1• Image8.ZOrder 0• Label5.Caption = "¡Correcto!"• Beep• Else• Label5.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

• Private Sub Image8_DragDrop(Source As Control, X As Single, Y As Single)• If Source = Image13.Visible = False Then• Image8.Picture = Image13.Picture• Image13.Visible = False• Label4.Caption = "¡Correcto!"• Beep• Else• Label4.Caption = "¡Incorrecto!"• End If• Call fin• End Sub

• Private Sub fin()• If Image9.Visible = False And Image10.Visible = False And Image11.Visible = False And Image12.Visible = False

And Image13.Visible = False And Image14.Visible = False And Image15.Visible = False And Image16.Visible = False Then

• Beep• Label1.Caption = "¡Ganaste!"• End If• End Sub