|
-
Jun 12th, 2002, 11:50 AM
#1
Thread Starter
Lively Member
Finding the path of a picture
I want a label to display the path of a picture box's picture... How would I do that?
Do you know if you will answer no to this question?
If we've never seen something happen, we can't know if its impossible.
If the soles of a shoe make faces at the floor when we don't look and isn't being watched via mirror or video tape, will we ever know?
If someone orders you to disobey all of their orders, do you obey or disobey?
-
Jun 12th, 2002, 01:18 PM
#2
Frenzied Member
I think the picture property returns a handle to the picture's memory address, but if you keep track of it's location you should be able to use something like this:
VB Code:
Public Function GetPath(ByVal FileName As String) As String
Dim intFound As Integer
intFound = InStrRev(FileName, "\")
If intFound > 0 Then GetPath = Mid(FileName, 1, intFound)
End Function
I haven't tested it but I think that's right.
-
Jun 12th, 2002, 01:39 PM
#3
Thread Starter
Lively Member
Do you know if you will answer no to this question?
If we've never seen something happen, we can't know if its impossible.
If the soles of a shoe make faces at the floor when we don't look and isn't being watched via mirror or video tape, will we ever know?
If someone orders you to disobey all of their orders, do you obey or disobey?
-
Jun 12th, 2002, 02:30 PM
#4
Frenzied Member
Hey Rick Bull... the idea is alright. But you forgot to declare InStrRev, I ran a project using it and it asked for a declaration for it.
Besides I also believe you should have given an example of how to use the code. I tried:
Private Sub Form_Load()
Label1.Caption = GetPath(Picture1)
End Sub
We miss you, friend...  Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
-
Jun 12th, 2002, 06:20 PM
#5
Frenzied Member
All right to use it you could have something like this:
VB Code:
Dim strPictureFileName As String, strPicturePath As String
strPictureFileName = "C:\Windows\Desktop\Picture.bmp"
strPicturePath = GetPath(strPictureFileName)
MsgBox(strPicturePath)
That should display "C:\Windows\Desktop". Obviously you will want to store the proper filename in strPictureFileName, not just "C:\Windows\Desktop\Picture.bmp".
And I didn't forget to declare InstrRev, it sounds like you have VB5 or eariler, you need 6. If you want the function I could probably work it out for you (if I can be bothered )
-
Jun 12th, 2002, 09:05 PM
#6
Frenzied Member
Nah... It is ok. I use VB4 indeed and VB5 CCE, I could upgrade to VB6 but I like the 4 better, I guess it is because of a certain something it has. Don't worry about giving the function, it can easily be declared by accessing the kernel32 but still, I think that if our friend did not have VB6 he would have had the same problem I did. Still, I consider your solution a good idea.
Just point out you need to know the location of the picture in order to display the path in the caption of the label, else if you are using the control (Like I did in the code I presented earlier) it will not show the source file you got the picture from.
We miss you, friend...  Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
-
Jun 13th, 2002, 06:14 AM
#7
Frenzied Member
I did say that in my first post
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|