• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

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

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.
0
Engtech05
Asked:
Engtech05
  • 3
  • 2
2 Solutions
 
Rey Obrero (Capricorn1)Commented:

imageName=mid(ImageLocation,instrrev(imagelocation,"/")+1)
0
 
Engtech05Author Commented:
I copied the code and tried it all I got was the file path, is there a different way?
0
 
Rey Obrero (Capricorn1)Commented:
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"

imageName=mid(ImageLocation,instrrev(imagelocation,"/")+1)

msgbox imageName

end sub


0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

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

0
 
Engtech05Author Commented:
Ok, I found the issue with the code the slash was backwards should have been "\" instead of "/".
Thanks for the help guys, points forthwith.
0
 
Engtech05Author Commented:
Just a minute fix but is works. Thanks again.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now