[RESOLVED] Storing Image of my admin and retreiving the image with all the other info txt files-VBForums
Results 1 to 13 of 13

Thread: [RESOLVED] Storing Image of my admin and retreiving the image with all the other info txt files

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    16

    Resolved [RESOLVED] Storing Image of my admin and retreiving the image with all the other info txt files

    I am saving and retreiving from textfiles.

    Saving the image as an imagepath and have added it to my user structure

    Writing :

    Code:
    User.Imagepath = txt_ImagePath.text
    Retreiving :

    Code:
    pbx_UserImage.image = User.Imagepath
    however there is an error (syntax blue line) that value of type string cannot be converted to system.drawing.image and I understand that but not sure how else it can be resolved

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,575

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    What we have here .... is failure.... to communicate.

    You've got a picturebox asking for an image. You've got a user object with a string. The fact that the string is the path and file name of an image, while significant, is irrelevant. Becausse that's not what the .Image property of the PB is equipped to receive. It can only receive an image object. So how do you get an image to pass to it? You create a New Image and .LoadFromDisk ... then you can set it to the .Image of the PB. Actually, I think the PB itself may also have a method that allows you to pass it a path & file name and it will load the image for you. Check the documentation on the PB.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    16

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    Not very helpful at all. Okay the communication isnt the best. Plus I know that what I am doing is wrong however I was wondering if someone could set me on the write tracks. The process you described is easier said than implemented. By saying go check out documentation on PB is possibly the worst feedback I have had from someone as I have actually already done that. Maybe in the feature when someone needs help try to approach it in a better manner than to say "failure" , thanks

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    31,575

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    Here's the documentation on the PB: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
    Here's the documentation on the Image property of the PB: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx -- It clearly does NOT take a string as its value.

    Either you read the wrong documentation, or you didn't look hard enough. Next time, link to it, or mention that you checked it out and couldn't make heads or tails of it.

    Point I was trying to make was that you're stuffing a quarter into a slot made for a dollar bill... That's a type mismatch. I tried to give you hints... even keywords... such as "New Image" and "LoadFromFile" ... I didn't realize that I also needed to copy those into Google and hit search too. I also mentioned that the PB might have a method to load from a file built-in ... it does. Two in fact. Load() and Load(string). I suggest looking at Load(string). These were easily found by going to the PictureBox entry and scrolling down to the Methods section and looking for something along the lines of "load" and bam, there they were.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    16

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    still cant manage to work it I dunno whats going on I followed that
    im trying the following :

    user 1
    name = John
    Surname = Wallis
    ImagePath = C:\Users\Sam\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\John.jpg

    user 2
    name = Tom
    Surname = Felin
    ImagePath = C:\Users\Sam\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\Tom.jpg

    Cant have it so that they will be able to save these images and retrieve them when i search their names
    all the other details are saved and retrieve fine.

    The best Ive reached is that its saving the image but it uses the same image for all users.

  6. #6
    Fanatic Member PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Newport, UK
    Posts
    738

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    Quote Originally Posted by Itsmethecoder123 View Post
    still cant manage to work it I dunno whats going on I followed that
    im trying the following :

    user 1
    name = John
    Surname = Wallis
    ImagePath = C:\Users\Sam\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\John.jpg

    user 2
    name = Tom
    Surname = Felin
    ImagePath = C:\Users\Sam\Documents\Visual Studio 2010\Projects\WindowsApplication1\WindowsApplication1\bin\Debug\Tom.jpg

    Cant have it so that they will be able to save these images and retrieve them when i search their names
    all the other details are saved and retrieve fine.

    The best Ive reached is that its saving the image but it uses the same image for all users.
    Sounds like you have something wrong in your code, but we can't really help unless you show us the code you are using to save and load these files.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    16

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    its just the saving and loading image part which is incorrect ill show you what i have done

    it writes the path fine with the record, however in the example provided above
    i will be able to see the image of john but when i create tom and with his filepath he will always be displayed in the picturebox for some reason

    Code:
      Dim UserImage As Image
    
       'Adding[CreateUserButton]
       User.ImagePath = Tbx_ImagePath.Text
       UserImage = Image.FromFile(Tbx_ImagePath.Text)
    
      
      'Retreiving[FindUserButton]
      Pbx_AdminImage.Image = AdminImage
    
    
    Module ModuleUser
    
        Structure User
            
            <VBFixedString(50)> Public ImagePath As String
           <VBFixedString(20)> Public Name As String
     <VBFixedString(20)> Public Surname As String
    
    
        End Structure

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    31,898

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    User shouldn't really be a structure. With a size that big, you would be stuffing a whole lot of bytes onto the stack if you ever passed a User as an argument to a method.

    However, that's not the issue here. The code you showed doesn't seem to cover the question. You create an image in UserImage, but the only time you assign to an Image property you are assigning AdminImage. Where did that come from?

    You probably don't need to go through the step of creating the image. TG mentioned that the PB has a method to load from a path. It's this one:

    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    So, you can probably just use that and bypass the need to create an image. Haven't tried it, though, cause I didn't know it existed.
    My usual boring signature: Nothing

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    16

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    Thanks for the input ! definately something im working on

    Sorry it should be userimage anything thats admin should be user

    dont understand that link sorry i tried to could you show me how ?

  10. #10
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    31,898

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    Are you saying that this:

    Pbx_AdminImage.Image = AdminImage

    should have been reading as:

    Pbx_AdminImage.Image = UserImage

    and that that doesn't work?

    That would be kind of suggestive, as the steps all seem reasonable. You get a path, you load an image from the path, then you assign that image to a picturebox. I haven't used that exact code in a long time, if ever, but it all seems plausible. So, if you aren't getting the image, it's time to do a bit of debugging. I'd be placing a breakpoint on the line where you assign the image to the PB. Does execution get there? If it does, then is the image something? If it is, then you are looking at the wrong picturebox by some means, but it's more likely that one of the earlier questions will be answered in the negative.
    My usual boring signature: Nothing

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    16

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    I managed to fix it not sure what was wrong but the problem I face now is :


    If i register you as a user and input your image path : C:\Users\Sam\Documents\Visual Studio 2010\Projects\SystemUser\SystemUser\bin\Debug\UserImages\Shaggy
    I can load your image fine (if it was there)

    Then if i register me as a different user and input a correct image path

    if i search myself and retreive my image it will work

    but then if i go to retrieve your record then it will basically retrieve my file path and display my image and its doing the same thing even if i was to introduce a 3rd user. The 3rd user would overwrite our image in picturebox even though its saving fine in the textfile (mine and your image filpath) so i think the problem is with the retreive button (code)

  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    31,898

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    That should probably be a different thread. It seems like it is likely to be a totally different problem. The retrieve button code might be the issue, and that's a good place to start.
    My usual boring signature: Nothing

  13. #13

    Thread Starter
    Junior Member
    Join Date
    Dec 2017
    Posts
    16

    Re: Storing Image of my admin and retreiving the image with all the other info txt fi

    ok thanks

Tags for this Thread

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width