You're only making a tit out of yourself. What is this? You first time getting drunk?
Irrational outbursts are apparently your forte, not mine.
Printable View
You're only making a tit out of yourself. What is this? You first time getting drunk?
Irrational outbursts are apparently your forte, not mine.
Calm Down you guys, I'm still relying on you guys for your help. I don't want this thread to become a thread war :(
I'm still having troubles with my program automatically loading the first picture of the list, it keeps telling me that the source file (image) does not exist.
Jason:
Are you coming off heroin or something coz chris sure didnt deserve that!
2ndly this doesnt make no sense at all!
"WHY DO YOU GUYS TURN SOMETHING SIMPLE INTO A HELL > ALL THAT CODE ISNT NEEDED MAN JUST KEEP IT LOW"
Almasy:
Sorry here ya go:
Private Sub Form_Load()
File1.Path = "C:\My Documents\"
File1.Pattern = "*.jpg;*.bmp"
image1.Picture = LoadPicture(File1.Path & "\" & File1.List(0))
End Sub
Hows that!
You have to put File1.Path before File1.List(0) because it only returns the filename otherwise (You need the whole path)
Sorry chrisjk I did Over Do It. We all are here to help each other its that im tired and slept only like 5 hours in 3 days and need rest
and Beacon please i wasnt talking to you keep out thanks
http://www.vbforums.com/avatar.php?u...line=994309904
im not on drugs mayber your drunk
I thought you wernt talking to me????
"im not on drugs mayber your drunk"
By the way your typing i wouldnt say i was the one drunk!
Please stop arguing :(
Anyways, how do I make it so that If I were to double click an image in my file1 it will show up in my image1?
Beacon, the code you told me still doesn't work.. :( Nothing Shows Up
1)
Private Sub File1_DblClick()
Dim strpic As String
strpic = File1.Path & "\" & File1.FileName
img.Picture = LoadPicture(strpic) 'loads picture
End Sub
2) It should do???
Any errors?
Well, I have a couple suggestions. You can use them or forget about them..
When I'm getting the path and filename so the image can be shown, I prefer not to just throw a backslash in the middle like Beacon did. This is because you end up having double-backslashes if the file is in the root directory (c:\, d:\, etc). Instead, I've made a PutSlash function that makes sure a string ends in a backslash:
VB Code:
Private Function PutSlash(sString As String) As String If Right(sString, 1) <> "\" Then PutSlash = sString & "\" Else PutSlash = sString End If End Function 'Now here is Beacon's code modified to use the PutShash 'function. It was also changed so it doesn't show an error if 'there are no images. Private Sub Form_Load() File1.Path = "C:\My Documents\" File1.Pattern = "*.jpg;*.bmp" On Error Resume Next Image1.Picture = LoadPicture(PutSlash(File1.Path) & File1.List(0)) End Sub 'If you want to show an image when the file list box gets double- 'clicked, this should do the trick. It also uses my PutSlash 'function. I suggest changing it so you show the file when it gets 'clicked instead of double-clicked. Private Sub File1_DblClick() Image1.Picture = LoadPicture(PutSlash(File1.Path) & File1.List(File1.ListIndex)) End Sub 'I also suggest using this code so the keyboard buttons can be 'used to switch images: Private Sub File1_KeyUp(KeyCode As Integer, Shift As Integer) Static LastIndex As Long On Error Resume Next If LastIndex <> File1.ListIndex Then Image1.Picture = LoadPicture(PutSlash(File1.Path) & File1.List(File1.ListIndex)) LastIndex = File1.ListIndex End If End Sub
Well It works wonders now, thank you everyone. I mostly imitated the source code that stickman showed. Thank you
I now use a txtPath to determine the destination
So this is my proposal, when I press cmdDirectory, I want a messege box asking for the new directory. Which will replace the current text in txtPath.
Also my images appear "ugly" when I set the image property to "stretch"so the image won't take up more than the designated area. Is there a way I can do a "best fit" of the area given?
Well you could just set stretch to false and the image box will resize itself accordingly!
And maybe have it check to see if it's too big for the form or set a maximum size!
2)
Perhaps do the following:
Make another form and set it's Border Style property to 4!
Then wack on a drive list box and a dir list box and then a command button called cmdOK.
Then add this code to that form:
VB Code:
Private Sub cmdOk_Click() Form1.File1.Path = Form2.Dir1.Path Form1.File1.Refresh Unload Me End Sub Private Sub Drive1_Change() Dir1.Path = Drive1.Drive End Sub
Add this to your cmdDirectory button:
VB Code:
Private Sub cmdDirectory_Click() Load Form2 Form2.Visible = True File1.Path = Form2.Dir1.Path File1.Refresh End Sub
I am currently using a picture1 instead of an image1 because with the skin thing that JasonLPZ introduced me to, it won't view images. But it will show pictures
*edit* I took a closer look at how JasonLPZ achieved his, I am currently using Image1 now :)
What I have yet to do is if I double-click an image in the filelistbox, it needs to come up to image1 directly. Can anyone help?
Almasy:
Both tygur and me posted code on how to do this!:confused:
I'm so sorry :( I'm so dumb. I'll check againQuote:
Originally posted by Beacon
Almasy:
Both tygur and me posted code on how to do this!:confused:
2 questions for now.
if I go into form2 to change directories, then pressing cancel = it will show my filelistbox in frmMain as blank and get the same error as above. I think the problem here is that even if I cancel, it still erases the current path that I have.
As for the "cancel" command for form2, I have
Private Sub cmdCancel_Click()
Unload Me
End Sub
-
Finally, last question for today before I go to sleep, is how do I make the folder un-defined because when I finish this program, I will be putting it on a CD, as a standalone with all the images in e:\data so I can't be relying on c:\my documents\my pictures
So what I'm trying to say is how do I make it so that the directory that is defined is ALWAYS below the path where the main .exe is located at. (i.e. if program.exe was in c:\ it would always look for c:\data and if it were in c:\program files it would always look for c:\program files\data
1)
Private Sub cmdDirectory_Click()
Load Form2
Form2.Visible = True
End Sub
2)
Use app.path for example:
If i had all my picture stored in the same folder as my application i'd do this:
File1.path = app.path & "\"
OR
if they were in a folder in the same directory as my app i'd do this:
file1.path = app.path & "\TEST\"
Hows that?
It works beautifully, thank you :) Well I'm off to sleep now, thank you all. I'll be back tomorow with more questions :D