viernes, 14 de mayo de 2010

EXPLORADOR DE IMAGENES VB

-En este programa crearemos un formulario nuevo donde visualizaremos mediante un drive, dirlistbox y filelistbox imagenes almacenadas en nuestro ordenador:


-Crearemos en el centro un image donde se mostraran las imagenes del ordenador :


Tambien deberemos crear dos botones uno de anterior y otro de siguiente, con el siguiente codigo en el interior de cada uno de ellos:
Private Sub Command2_Click()


On Error Resume Next

File1.Selected(File1.ListIndex - 1) = True

End Sub

Private Sub Command1_Click()

On Error Resume Next

File1.Selected(File1.ListIndex + 1) = True

End Sub
 
 
 
Para poder retroceder y abanzar se introducira el codigo anterior y en los dirlistbox,filelistbox y drive:
Private Sub Dir1_Change()


File1.Path = Dir1.Path

Dir1.Path = Drive1.Drive

End Sub

Private Sub Drive1_Change()

On Error Resume Next

Dir1.Path = Drive1.Drive

End Sub



Private Sub File1_Click()

Image1.Picture = LoadPicture(Dir1.Path & "\" & File1.FileName)

End Sub




Private Sub Form_Load()

File1.Pattern = "*.bmp;*.gif;*.jpg"

Image1.Stretch = True

End Sub

I este es el resultado final del proyecto de explorador de imagenes:



DEPOSITO DE COMBUSTIBLE

-En este proyecto de visual basic crearemos un deposito de combustible que se debera llenar y vaciar:



















-El deposito debera vaciarse al hacer clic en el optionbutton de "vaciar" y llenarse con el boton "llenar"  con el siguiente codigo en el correspondiente timer:





Private Sub Timer2_Timer()


If Option1.Value = True Then

incremento = 20

Else

incremento = -20

End If

If Text1.Top - incremento <= Picture1.Top + Picture1.Height * 0.9 Then

If Text1.Height + incremento <= Picture1.Height Then

Text1.Height = Text1.Height + incremento

Text1.Top = Text1.Top - incremento

Else

Text1.Height = Picture1.Height

End If

End If

End Sub



-Tambien deberemos poner un BOTON para iniciar el llenado con codigo siguiente:





Private Sub start_Click()

Timer2.Enabled = True

End Sub
 
-Cuando clickemos en el option buton vaciar el bidon se vaciara, debera tener el siguiente aspecto: