Results 1 to 4 of 4

Thread: [RESOLVED] could u say "whether i can use a string to represnt a picture or not?"

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Resolved [RESOLVED] could u say "whether i can use a string to represnt a picture or not?"

    Hi All,
    Here my doubt is regarding to a picture box in VB 6.0

    assume that i have few picture boxes in my appliaction named Picture1,picture2,picture3..etc.

    And in my application, i have to load the pictures dynamically. i can load like...
    Picture1.picture=Load picture("path of a .bmp)
    Picture2.picture=Load picture("path of a .bmp)
    Picture3.picture=Load picture("path of a .bmp)

    But i am not interested to load like this. i want to write a method like this..

    private sub subLoadPictures(byval pictrueName as string, byval PicturePath as string)
    pictureName.picture=load picture(picturepath)
    end sub

    I tried this one, but could not get working properly.. could u please say how to use a string that represents the name of a picture.

    Thanks:
    regards:
    raghunadhs.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: could u say "whether i can use a string to represnt a picture or not?"

    probably picturename should be picturename as picturebox, also check spelling
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: could u say "whether i can use a string to represnt a picture or not?"

    You can also use the Me.Controls collection, ex:

    vb Code:
    1. Private Sub SetPicture(PBName As String, FilePath As String)
    2.     Me.Controls(PBName).Picture = LoadPicture(FilePath)
    3. End Sub
    4.  
    5. Private Sub Command1_Click()
    6.     SetPicture "Picture1", App.Path & "\image.bmp"
    7. End Sub

    Kind of pointless though.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2007
    Posts
    167

    Re: could u say "whether i can use a string to represnt a picture or not?"

    Thanks DigiRev and WestConn1

    It is working... thanks alot

    regards:
    raghunadhs.

    Quote Originally Posted by DigiRev
    You can also use the Me.Controls collection, ex:

    vb Code:
    1. Private Sub SetPicture(PBName As String, FilePath As String)
    2.     Me.Controls(PBName).Picture = LoadPicture(FilePath)
    3. End Sub
    4.  
    5. Private Sub Command1_Click()
    6.     SetPicture "Picture1", App.Path & "\image.bmp"
    7. End Sub

    Kind of pointless though.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width