How do I get the Name of an image returned to a text box

Posted on 2011-10-10
Last Modified: 2012-05-12
I have looked through the knowledge base and can't find anything on getting just the image name from a image then populating a text box with it.
String functions probably will not work because of the varying length of image names in the file path. Not sure if I can get it from a  "Name" function or not.
Example: subStr = ImageLocation
ImageLocation = ("C:/ users/jschmuck/locations/images/Axes/axe1.jpg")

All I want is the axe1.jpg, but the image name could have 3-25 characters.
Such as Unk_Ax_VP1.jpg 0r VP_Aux_Unk_3.jpg

All help is greatly apreciated.
Question by:Engtech05
    LVL 119

    Accepted Solution



    Author Comment

    I copied the code and tried it all I got was the file path, is there a different way?
    LVL 119

    Assisted Solution

    by:Rey Obrero
    what do you mean by, all I got was the file path?
    check your the content of  imageLocation..

    try the function with this

    sub getImageName()

    dim imageLocation as string, imageName
    imagelocation="C:/ users/jschmuck/locations/images/Axes/axe1.jpg"


    msgbox imageName

    end sub

    LVL 2

    Expert Comment

    Can you explain just a little more about what you are trying to do.
    Are you trying to read a directory that has an image in it? or pull some information from the database and populate fields with it?

    if you always know the location of the file you could always use an explode() or a preg_split() to get the part that you want isolated from the whole file location.

    if i have more of an idea of what you are trying to do, I may be able to help better
    $location = "C:/users/jschmuck/locations/images/Axes/axe1.jpg";
    $fileName = explode("/", $location);
    echo $fileName[7];

    Open in new window


    Author Comment

    Ok, I found the issue with the code the slash was backwards should have been "\" instead of "/".
    Thanks for the help guys, points forthwith.

    Author Closing Comment

    Just a minute fix but is works. Thanks again.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now