#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2010
    Posts
    6
    Rep 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:
    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.
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,453
    Rep Power
    4539
    What version of vb?

    You probably should be looking at a for each loop

    Comments on this post

    • medialint agrees : Yes, a for .. each would help
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2011
    Posts
    23
    Rep Power
    0

    you need to show the problem


    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:
    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

    post some more!

    bill stewart - here to listen

IMN logo majestic logo threadwatch logo seochat tools logo