Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / VB files

Author
Message
Edizzle
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 29th Sep 2004 06:40
Any one know the commands in Visual Basic 6 to make/open/edit/delete files so you can save info and then open it up again. Thanks!

http://edizzle.100free.com
John Y
Synergy Editor Developer
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: UK
Posted: 29th Sep 2004 07:06
There are many ways to do it.

Look into the open command.

CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 29th Sep 2004 08:32
if you need heavy duty stuff then include a reference to MS Scripting Runtime in your project then you have full access to FileSystemObject (fso) - its as good as youll get in vb6 for files/dirs functions

if you just need basic stuff then look into

Open, print, lineinput, close, freefile()
commands


DBP_NETLIB_v1.4.3 DarkTOPIA site coming soon!
Giles Papworth
21
Years of Service
User Offline
Joined: 7th Feb 2003
Location: In my own little reality
Posted: 29th Sep 2004 08:59
I would use the file system object myself. In the referances find Microsoft scripting runtime.

Then in your sub routine do this:



with the fso (file system object) you can also check if files or folders exist and such like:


Look into the file system object in the msdn library, or alternativly ask us here

Happy coding

Its not a bug, Its a feature

If we were meant to stay in this reality games would not exist!
Edizzle
20
Years of Service
User Offline
Joined: 22nd Aug 2004
Location:
Posted: 29th Sep 2004 09:34
ya but for

Dim fso as FileSystemObject

i just get

compile error:
user-defined type not defined

what am i doing wrong or what am i not doing

"if you need heavy duty stuff then include a reference to MS Scripting Runtime in your project then you have full access to FileSystemObject (fso) - its as good as youll get in vb6 for files/dirs functions"
how do i script

man VB is close to but miles away from DB, hard move

http://edizzle.100free.com
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 29th Sep 2004 10:42 Edited at: 29th Sep 2004 10:43
In the VB IDE, go to the 'Project' menu item, then go down to 'References'. Scroll through that list until you find 'Microsoft Scripting Runtime', check that option and click 'OK'. Then Giles code will work. Actually, I just noticed Giles has an error in his code, it should actually be:



And remember Tempstring will hold all your text after it's executed.

Also, the more 'conventional' method for opening files in VB (which doesn't require the MS Scripting Runtime reference) is to just use this:



Obviously 'Variable' will hold your text, although, that code will only pull out the first 'segment' of the file, a 'segment' being a line of text in a file until a comma is reached, i.e. If your file looked like:

"Testing this file, Ok it's good
Now onto a new line"

That code will only pull the "Testing this file" part, which is why this code is only really good if you've already saved to the text file previously with VB, so you can easily match the format.


"Computers are useless they can only give you answers."

Login to post a reply

Server time is: 2024-09-22 18:30:14
Your offset time is: 2024-09-22 18:30:14