Tesdall Posted December 6, 2003 Posted December 6, 2003 Im trying to figure out how to make one button fire many events..but have it button click driven .. i have let say 3 picturebox's on the screen all .visabel = false so when they click the "show" button one appears...then click again 2 appear .. and so on ..can someone help ? click button picture 1 appears click button picture 1 is still there picture 2 appears click button pic1 pic2 + pic 3 here you put picturebox(last) it keeps saying "picturebox is not a type that can be used for this" Static mlngLast As Long Inherits System.Windows.Forms.Form Dim Last As Byte Private Sub btnPresents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPresents.Click Static Last As Long Static mingLast As Long If mingLast <= PictureBox2.UBound Then PictureBox2(mingLast).Visible = True mingLast = mingLast + 1 End If End Sub have pictuebox2 (just to be generic) but its squiggled out .. ? Quote
Leaders dynamic_sysop Posted December 6, 2003 Leaders Posted December 6, 2003 you could set an integer up , then depending on it's value show the pictureboxes. eg: Private PictureToShow As Integer = 0 Private Sub btnPresents_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPresents.Click If PictureToShow = 0 Then '/// show the first picture box PictureToShow += 1 ElseIf PictureToShow = 1 Then '/// show 2nd pic box. PictureToShow += 1 ElseIf PictureToShow = 2 Then '/// show 3rd pic box PictureToShow += 1 '/// value now set to 3 , so no more pic boxes to show. End If End Sub Quote
Tesdall Posted December 6, 2003 Author Posted December 6, 2003 where do you declare what piocturetoshow is ? Quote
Leaders dynamic_sysop Posted December 6, 2003 Leaders Posted December 6, 2003 above your subs ( just below all your Windows Generated Code stuff ) Quote
Tesdall Posted December 6, 2003 Author Posted December 6, 2003 i tried that code.. however it doesn't work ? im still new but i know enough to get into trouble ^_^ . for generic reasons the button needs to open picturebox2, 3, 4. so when i click the button im sure it "works" but it does do what i need it to do. Quote
Leaders dynamic_sysop Posted December 6, 2003 Leaders Posted December 6, 2003 (edited) i've knocked up a quick example project for you and attached it , the basis of the code is ... Private PicturesToShow As Integer = 0 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If PicturesToShow = 0 Then PictureBox1.Visible = True ElseIf PicturesToShow = 1 Then PictureBox2.Visible = True ElseIf PicturesToShow = 2 Then PictureBox3.Visible = True End If PicturesToShow += 1 End Sub edit: removed binariesshow pictureboxes.zip Edited December 6, 2003 by Nerseus Quote
Tesdall Posted December 6, 2003 Author Posted December 6, 2003 omg thanks muchly! that works great ^_^ , now how do you do a mass clear ? do you happen to know ? Quote
Jay1b Posted December 7, 2003 Posted December 7, 2003 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click picturebox1.visible = false picturebox2.visible = false picturebox3.visible = false End Sub Quote
Jay1b Posted December 7, 2003 Posted December 7, 2003 Really you need to look into understanding the way coding works. Take each individual line on its own, then you can simply repeat it (as above) as when needed and whenever necessary. Things like if statements work as follows IF condition = something THEN lines of code ELSEIF condition = something_else THEN 'optional lines of code ELSE 'optional lines of code 'happens when neither of the conditions are met END IF Now you can put almost any thing into the 'lines of code' part and it will only activate it when the condition is met. In other words, learn each bit individually - when you know it you can merge them together with no trouble at all. Quote
Tesdall Posted December 7, 2003 Author Posted December 7, 2003 i know about the if then statemtnt and other statements .. case statements and things like such.. im just not very good at knowing how "deep" they can go. as if then statement i thought it could be ... IF something THEN THIS END IF or IF something THEN messagebox.show ELSEIF endif Quote
Tesdall Posted December 7, 2003 Author Posted December 7, 2003 i understand but why want a mass clear is this, im just messing around and i have something that has 70+ picturebox's... now maybe you understand why i want a mass clear button like CLEAR.ALL or something (if there was something easy like that) Quote
Tesdall Posted December 7, 2003 Author Posted December 7, 2003 (edited) im done .. and its kinda big... er.. its pretty stupid im just having fun ^_^ if you do try it. please just keep my credit in it. [edit]Attachement removed, please don't post binary files in attachements.[/edit] Edited December 7, 2003 by mutant Quote
Administrators PlausiblyDamp Posted December 7, 2003 Administrators Posted December 7, 2003 Your attachment contains binaries - could you remove them and reattach the zip. But the following should work for you. Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click Dim p As PictureBox For Each c As Control In Me.Controls If TypeOf c Is PictureBox Then p = DirectCast(c, PictureBox) p.Visible = False End If Next End Sub Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jay1b Posted December 7, 2003 Posted December 7, 2003 Bloody hell Plaus' you are good at this arent you ;) Quote
Tesdall Posted December 7, 2003 Author Posted December 7, 2003 ... binary ???as if i knew what that ment or how to get rid of it Quote
Tesdall Posted December 7, 2003 Author Posted December 7, 2003 however i know binary code .. but not what it means in VB .. that code however f***ing rocks ^_^ thanks Quote
*Experts* mutant Posted December 7, 2003 *Experts* Posted December 7, 2003 Binary files refers to an executable file or a DLL. Quote
Tesdall Posted December 7, 2003 Author Posted December 7, 2003 ooohh... .^_^ thats what he ment ... then how can i post this "project" ?? just leave out the bin file ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.