Discuss Control looping problem for newbie in the Visual Basic Programming forum on Dev Shed. Control looping problem for newbie Visual Basic Programming forum discussing VB specific programming information. Quickly prototype and build applications with this robust and simple language.
Posts: 6
Time spent in forums: 1 h 14 m 41 sec
Reputation Power: 0
Control looping problem for newbie
Hi there
i have a relatively simple task which is driving me mad!!
I have 80 picturebox's on a form and want to loop through each one to 'save' the name only (not the image) of the image. i have tried:
LstCount = 0
Dim bmp As Bitmap
Dim ctl As Control = Me
Do
ctl = Me.GetNextControl(ctl, True)
If ctl IsNot Nothing Then
' Search for a TextBox
If TypeOf ctl Is PictureBox Then
'MessageBox.Show(ctl.Name)
Code:
Original
- Code
bmp = ctl.Image
LstCount = LstCount + 1)
End If
End If
Loop Until ctl Is Nothing
MsgBox(LstCount)
The messagebox.show works with presenting the picbox control names but if i try to use the .image syntax it says the 'image' is not a member of the system.windows.forms.control.!!
Any help please.
Regards
David
ps, once i have the image name im going to pass it off to a 'save' option and write each name and image name to a seperate file.
Posts: 14,257
Time spent in forums: 1 Month 4 Weeks 19 h 1 m 26 sec
Reputation Power: 4445
What version of vb?
You probably should be looking at a for each loop
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi
Posts: 23
Time spent in forums: 4 h 48 m 40 sec
Reputation Power: 0
you need to show the problem
Quote:
Originally Posted by gingernob
Hi there
i have a relatively simple task which is driving me mad!!
I have 80 picturebox's on a form and want to loop through each one to 'save' the name only (not the image) of the image. i have tried:
LstCount = 0
Dim bmp As Bitmap
Dim ctl As Control = Me
Do
ctl = Me.GetNextControl(ctl, True)
If ctl IsNot Nothing Then
' Search for a TextBox
If TypeOf ctl Is PictureBox Then
'MessageBox.Show(ctl.Name)
Code:
Original
- Code
bmp = ctl.Image
LstCount = LstCount + 1)
End If
End If
Loop Until ctl Is Nothing
MsgBox(LstCount)
The messagebox.show works with presenting the picbox control names but if i try to use the .image syntax it says the 'image' is not a member of the system.windows.forms.control.!!
Any help please.
Regards
David
ps, once i have the image name im going to pass it off to a 'save' option and write each name and image name to a seperate file.
doug has suggested a different loop structure that would simplyfy some of you code and stop you walking beyond the controls on your form...
but that is not the issue here
the problem is that you have not included an example that works and what is gives you and the example of what you have tried and failed with.
simply saying the message box worked with the ctl but not the .image does not show how you sued these words witin your code