Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

vb 2005 help


  • Please log in to reply

#16
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts

no problem, just let me know if you have any more questions.


i have found another problem :[

i have an add image facility that works the same as all the sections in the array, i have an open dialog box and the user selects there picture and then the file path is put into the array as a string. this works fine, saves and lods ok. but i have the problem that i have to display it on another computer and load up the file i have already saved for a demonstration. the only problem is it saves the full file path so when i load it up from any other computer it wont find it. i can edit it in the text fole so they are reletive paths and the program reads that fine but in the actual program i cant find a way to just get the reletive file path in the array instead of the whole file path.
any ideas?
  • 0

Advertisements


#17
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts
oh and the code i am using to do that is just

.dvdimage = OpenFileDialog1.FileName
  • 0

#18
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
i'm a bit confused... why not, when installing the program on another computer for demonstration purposes, just put the pictures in the same place as on the original computer? This problem shouldn't come up in regular use though, unless the user moves or deletes the pictures.
  • 0

#19
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts

i'm a bit confused... why not, when installing the program on another computer for demonstration purposes, just put the pictures in the same place as on the original computer? This problem shouldn't come up in regular use though, unless the user moves or deletes the pictures.


because it uses the whole file path like
C:\Documents and Settings\My Documents\programming\program\bin\Debug\fifth_element-spb_petr-640.jpg
when doing this on another computer the file path with have changed if i just copy the whole program folder onto another computer.

i thought there was a way when you were saving you could just use the relative path like 'fifth_element-spb_petr-640.jpg' but i dont know how to get that when reading in straight from a dialog box.

and to add insult to injury i just found that he save function is no longer working for some reason can you see anything wrong with that

Dim outputfile As IO.StreamWriter
outputfile = IO.File.CreateText("DVDs.txt") 'Creates a text file to write to

Dim i As Integer

For i = 1 To numdvds
With Details(i)
outputfile.WriteLine(.Title)
outputfile.WriteLine(.Director)
outputfile.WriteLine(.Year)
outputfile.WriteLine(.Rating)
outputfile.WriteLine(.dvdimage)
outputfile.WriteLine(.widescreen) 'writes each line of the array to the text file until it reaches the end of the array
End With
Next i

outputfile.Close()


doesnt seem any different than it was when it worked.


sorry about this.
  • 0

#20
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts
ive sorted the save part now so ignore that sorrry.
any ideas on the pictures though and i would be very greatful
  • 0

#21
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
Could you give me all relevant code about both the .widescreen array item and the .dvdimage array item?

Edited by stettybet0, 18 April 2007 - 02:28 PM.

  • 0

#22
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts

Could you give me all relevant code about both the .widescreen array item and the .dvdimage array item?



add button is

If Val(TxtaddRating.Text) > 5 Then
MsgBox("Please enter a number between 1 and 5") 'makes sure the user enters a number equal to or less than 5
Else
If Val(TxtaddRating.Text) < 1 Then
MsgBox("Please enter a number between 1 and 5") 'makes sure the user enters a number equal to or more than 1
Else
numdvds = numdvds + 1 'adds one to numdvds
ReDim Preserve Details(numdvds) 'preserves the data already in the array
With Details(numdvds)
.Title = Txtaddtitle.Text
.Director = TxtaddDirector.Text
.Year = TxtaddYear.Text
.Rating = Val(TxtaddRating.Text)
.dvdimage = OpenFileDialog1.FileName
.widescreen = Chkboxwidescreen.CheckState ' adds all data into each section of the array
End With

when i go to load them from the file its

Dim i As Integer
i = numdvds
Dim inputfile As IO.StreamReader
inputfile = IO.File.OpenText("DVDs.txt") 'opens the file to read from
While Not inputfile.EndOfStream
i = i + 1
ReDim Preserve Details(i) 'preserves the dat already in the array
With Details(i)
.Title = inputfile.ReadLine()
.Director = inputfile.ReadLine()
.Year = inputfile.ReadLine()
.Rating = inputfile.ReadLine()
.dvdimage = inputfile.ReadLine()
.widescreen = inputfile.ReadLine() 'reads in all the lines from the text file into the array
End With
numdvds = i
End While
inputfile.Close()

With Details(0)
TxtTitle.Text = .Title
TxtDirector.Text = .Director
TxtYear.Text = .Year
TxtRating.Text = Ratingstars(.Rating)
PBoximage.ImageLocation = .dvdimage
chkboxwidescreen.Checked = .widescreen 'makes the main form show the information from the first film in the array
End With
  • 0

#23
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
I don't think it's possible to get a relative path from an open file dialog. That would defeat the purpose.

A solution:

Take C:\Documents and Settings\My Documents\programming\program\bin\Debug\fifth_element-spb_petr-640.jpg and save it in an easy place like C:\fifth_element-spb_petr-640.jpg

Then, add it to the array data and save the array.

Then, on the demonstration computer, copy the fifth_element-spb_petr-640.jpg to C:\fifth_element-spb_petr-640.jpg so that the demonstration array data will be valid.

Either that, or you could use just a textbox to load the image, and I know how to do relative paths in that. However, the user would need to know the name of the picture they wanted to use. (ie. they would need to know "fifth_element-spb_petr-640.jpg")
  • 0

#24
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
An idea just popped into my head... are all the pictures in the same folder currently? And if not, could they easily be placed there?
  • 0

#25
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts

An idea just popped into my head... are all the pictures in the same folder currently? And if not, could they easily be placed there?

yes they are :]
why?
  • 0

Advertisements


#26
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
Assuming all your pictures are saved in: C:\Documents and Settings\My Documents\programming\program\bin\Debug\

This should work added to the very beginning of the add button:
OpenFileDialog1.FileName = OpenFileDialog1.FileName.Remove(0, 69)

  • 0

#27
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts

Assuming all your pictures are saved in: C:\Documents and Settings\My Documents\programming\program\bin\Debug\

This should work added to the very beginning of the add button:

OpenFileDialog1.FileName = OpenFileDialog1.FileName.Remove(0, 69)


is that to just remove the amount of characters in the string?
would i then have to change the amount if the file location was different on the other computer?
  • 0

#28
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
it should work without any other changing.

It will edit the filename so that it will just read: "fifth_element-spb_petr-640.jpg" instead of "C:\Documents and Settings\My Documents\programming\program\bin\Debug\fifth_element-spb_petr-640.jpg". That will make it so that it reads the file from the same folder as the program's executable is located. So, when you build your executable, take it, DVDs.txt, and all the picture files and save them in the same place on the demonstration computer. Then, everything should work fine.

WARNING
If the pictures are NOT in the same folder as the executable, then this will not work. For this reason, you should NOT include this code in your final product.
  • 0

#29
jeffsimmo85

jeffsimmo85

    Member

  • Topic Starter
  • Member
  • PipPip
  • 16 posts
ah i see, thanks alot. your helps been REALLY great
cheers
  • 0

#30
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
you're welcome. let me know if it worked out.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP