Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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 .. ?

  • Leaders
Posted

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

Posted

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.

  • Leaders
Posted (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 binaries

show pictureboxes.zip

Edited by Nerseus

Posted
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

Posted

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.

Posted

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

Posted

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)

Posted (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 by mutant
  • Administrators
Posted

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

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...