how do you open a file in VB6?
I understand how to write to a file and read a file, but I just want the file to open for viewing.
(I'd like to be able to choose the file from within the code, so a list box won't work for what I'm wanting to do)
6 1530
how do you open a file in VB6?
I understand how to write to a file and read a file, but I just want the file to open for viewing.
(I'd like to be able to choose the file from within the code, so a list box won't work for what I'm wanting to do)
That depends on what you mean by "open for viewing". There's no magic "view file" statement. If you want to get the contents of the file on-screen, you need to put them there. A couple of relatively simple ways that come to mind are: - Use Shell statement to open Notepad to display it
- Open it for reading and copy the contents into a TextBox control (make sure you set Multiline property to True)
- Open it for reading and copy the contents into a RichTextBox control
- Come up with your own variation
Not sure what you mean about the list box.
by "list box" I meant a box that displays files that are on your computer. ...I've had to learn a lot of Visual Basic in a short period of time, so whenever I get stuck I flip through this book I have, and that's the only way it showed to open files ...it basically lists what files exist, and you select the file you want, but the way that's done in the book won't work for what I'm trying to do. (hopefully that makes sense)
anyway, I'm not exactly sure what type of file I'll need to be opening. It could be Access files or text files or some other form of data file.
I believe I've written code in C++ that opens an existing text file and displays it on the screen. (I could be wrong...now I'm not so sure)
but, anyway, it's not data that needs to be changed or appended to. I just need to open the files. It seems like there should be a way to do it. I actually have done it with excel files, but that was specifically for opening excel sheets.
what I have is a program with a lot of data. The file names are contained at various places in the data. So, I want to put all of that data together, and basically say, "open this file".
...what I have is a program with a lot of data. The file names are contained at various places in the data. So, I want to put all of that data together, and basically say, "open this file".
Yes, but the question still remains - what, precisely, do you mean by "open" in this context. The word can mean quite different things.
In Visual Basic, to "open" a file means to set up various pointers and buffers so that your program can access and/or modify the data contained in the file and, depending on the options specified, prevent others from accessing and/or modifying the file. This is achieved by use of the Open statement. These options remain in effect until you close the file.
If you mean something else, then please be precise.
Sorry for the confusion.
Okay, I want to be able to insert into my code something like...
"example.txt" or "example.dat"
as a file to be opened.
I don't want visual basic to do ANYTHING other than open the file. Basically, I'm looking to write some code that will keep me from having to go through file directories looking for a file.
for example, if I'm looking for "example.txt", I would have to go to "C:" then "C\Documents and Settings" ...and so on.
I want a program that will find this file (I will have the exact location of the file determined in the program), and I want this file to simply open on the screen.
So, this program (in VB) will simply locate a file on my computer and open it. Once the file is opened, VB will be done. Then the user can do whatever they want with the file that was opened.
hopefull this makes sense. Thanks for bearing with me.
Hello on regards to Opening a File.
I have created (from VB inside ACCESS) a tblDir that Displays in a MS-ACCESS table. I would also like to click on a line item of the items displayed and then open the associated program to display (read/write, etc) the file. E.g., ADOBE for PDF, MSWord for *.DOC, viewer for *.TIF and so on. Any suggestions or help. I'm up through the tblDir display in an ACCESS form.
I believe both of you should do a search for information on the FindExecutable API.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: PM |
last post by:
Has anyone found a way to open a file exclusively where it
will fail if the file is already open, i have tried the
following
_FileStream = new FileStream(@"C:\Data.txt",
FileMode.Open,...
|
by: Alfons |
last post by:
Hello,
I have build a program that can do file transferring between a Windows
XP computer and a DOS computer via a serial port. The Windows program
I have build in C++ with Visual Studio 6.0....
|
by: D. Alvarado |
last post by:
Hello,
I am trying to open a window containing an image and I would like
the image to be flush against the window -- i.e. have no padding or
border. Can I make this happen with a single call to a...
|
by: Brad |
last post by:
In several aspx applications I export crytal reports to pdf, xls and doc
files and then the aspx page writes the selected export file to the client
browser. This all works with one small quirk: ...
|
by: aldrin |
last post by:
I'm trying to run this code under windows xp sp2 using codeblocks v1.0
compiler with great difficulty.There is no problem with running this
under KDevelop in linux. Any help would be greatly...
|
by: Craig |
last post by:
Hi there,
I'm trying to open colour BMPs using PIL and I'm getting the following
errors.
Opening a 16 colour BMP I get:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in...
|
by: compman9902 |
last post by:
Hello, and thank toy for reading this post.
Thus far, this website has helped me a lot,
(I have finally finished my encryptor: "site removed by moderator", go to the downloads link) and I will...
|
by: Umesh |
last post by:
how to open a website like yahoo.com and use it as input? The
following code doesn't work.
#include"stdio.h"
int main()
{
FILE *f;
f=fopen("http://www.yahoo.com","r");
if(f==NULL)
|
by: Sanjeeva K kanakam |
last post by:
Hi all, I am developing one application. In that i have created on report file which contains tables, titles and tree view list also by using HTML tags. I am opening this file in my application it...
|
by: Alexnb |
last post by:
Gerhard Häring wrote:
No, it didn't work, but it gave me some interesting feedback when I ran it
in the shell. Heres what it told me:
Traceback (most recent call last):
File...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |