| | |
About Picture Box in Visual Box Help Please!
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
im beginner in visual basic can anyone help me please?
i have 1 command botton and 1 picturebox
my command button name is Switch
every time i click my command button Switch the image in the picturebox change
for example i have already an image in the picturebox Sunset image
if i click my command Button the image change to Winter
if i click once again my command button the image should change to Sunset
if i click it again the image should Winter in the picture box
heres my code in form load
Private Sub Form_Load()
picture1.picture = LoadPicture("D:\hehe\Winter.jpg"
End Sub
please help me badly needed! god bless you daniweb and more power!
i have 1 command botton and 1 picturebox
my command button name is Switch
every time i click my command button Switch the image in the picturebox change
for example i have already an image in the picturebox Sunset image
if i click my command Button the image change to Winter
if i click once again my command button the image should change to Sunset
if i click it again the image should Winter in the picture box
heres my code in form load
Private Sub Form_Load()
picture1.picture = LoadPicture("D:\hehe\Winter.jpg"
End Sub
please help me badly needed! god bless you daniweb and more power!
•
•
Join Date: Nov 2008
Posts: 29
Reputation:
Solved Threads: 4
u try the code snippet:
Private Sub cmdSwitch_click()
if picture1.picture ="D:\hehe\Winter.jpg" then
picture1.picture = LoadPicture("D:\hehe\Sunset.jpg"
else
picture1.picture = LoadPicture("D:\hehe\Winter.jpg"
end sub
this would do for switch
similarly for the pictue click change in picture write the same code in the picture1_click event...
this should solve ur problem
Private Sub cmdSwitch_click()
if picture1.picture ="D:\hehe\Winter.jpg" then
picture1.picture = LoadPicture("D:\hehe\Sunset.jpg"
else
picture1.picture = LoadPicture("D:\hehe\Winter.jpg"
end sub
this would do for switch
similarly for the pictue click change in picture write the same code in the picture1_click event...
this should solve ur problem
dont just copy the code,match the braces
it is just a code snippet
so use the correct syntax
also check the button name....i mean ur caption is switch ,so i assumed ur button name to be cmdSwitch..
it is just a code snippet
so use the correct syntax
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Private Sub cmdSwitch_click() if picture1.picture ="D:\hehe\Winter.jpg" then picture1.picture = LoadPicture("D:\hehe\Sunset.jpg") else picture1.picture = LoadPicture("D:\hehe\Winter.jpg") end sub
Chazing Dreams ;'P
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
Shhhh.......ZZzzzzzzzzzzzzzzzzzzzz.....
•
•
Join Date: Jul 2008
Posts: 161
Reputation:
Solved Threads: 1
the error is type mismatch that is the code i put in my command button still got error type mismatch
here's my code in my command button:
Private Sub Command1_Click()
If Picture1.Picture = "D:\hehe\Winter.jpg" Then
Picture1.Picture = LoadPicture("D:\hehe\Sunset.jpg")
Else
Picture1.Picture = LoadPicture("D:\hehe\Winter.jpg")
End If
End Sub
still not work huhuhu
here's my code in my command button:
Private Sub Command1_Click()
If Picture1.Picture = "D:\hehe\Winter.jpg" Then
Picture1.Picture = LoadPicture("D:\hehe\Sunset.jpg")
Else
Picture1.Picture = LoadPicture("D:\hehe\Winter.jpg")
End If
End Sub
still not work huhuhu
Hi,
Its always Better to Keep a Static Boolean Variable in such cases...
Try this :
Static Variables are Variables declared within the Procedure and retain their values as long as the code is running
Regards
Veena
Its always Better to Keep a Static Boolean Variable in such cases...
Try this :
vb Syntax (Toggle Plain Text)
Private Sub Command1_Click() Static TFlag As Boolean If TFlag Then Picture1.Picture = LoadPicture("D:\hehe\Sunset.jpg") Else Picture1.Picture = LoadPicture("D:\hehe\Winter.jpg") End If TFlag = Not TFlag End Sub
Static Variables are Variables declared within the Procedure and retain their values as long as the code is running
Regards
Veena
![]() |
Similar Threads
- Visual Basic coding for excel database - am tearing my hair out! (Visual Basic 4 / 5 / 6)
- simple paint similar to MS Paint.. I have qustions! (VB.NET)
- how to open picture in vb by oading internet explorer (Visual Basic 4 / 5 / 6)
- need help with PICTURE (Visual Basic 4 / 5 / 6)
- Visual C++ Form Project - need to get HDC for drawing bitmaps (C++)
- Network cable is un-plugged! No it isn't. (Networking Hardware Configuration)
- Internet explorer terminating at will. (Viruses, Spyware and other Nasties)
- Explorer.exe terminting at will (Windows 95 / 98 / Me)
- Microsoft .NET FAQ (ASP.NET)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: communication protocol for Endress-Hauser recorders
- Next Thread: Program not Working after deploying
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





