Buttons

Tesdall

Newcomer
Joined
Dec 6, 2003
Messages
11
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 .. ?
 
you could set an integer up , then depending on it's value show the pictureboxes. eg:
Visual Basic:
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
 
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.
 
i've knocked up a quick example project for you and attached it , the basis of the code is ...
Visual Basic:
    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 binaries
 

Attachments

Last edited by a moderator:
omg thanks muchly! that works great ^_^ , now how do you do a mass clear ? do you happen to know ?
 
Visual Basic:
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
 
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

Visual Basic:
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.
 
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
 
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)
 
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]
 
Last edited by a moderator:
Your attachment contains binaries - could you remove them and reattach the zip.
But the following should work for you.
Visual Basic:
    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
 
however i know binary code .. but not what it means in VB .. that code however f***ing rocks ^_^ thanks
 
ooohh... .^_^ thats what he ment ... then how can i post this "project" ?? just leave out the bin file ?
 
Back
Top