944,057 Members | Top Members by Rank

Ad:
Dec 20th, 2005
0

file open code in VB

Expand Post »
How does one create the process where a user can open (select) a file to read from? In C++ there are already classes to inherit from. Do I have to make a file open form from scratch in VB?
Similar Threads
Reputation Points: 17
Solved Threads: 0
Junior Poster
complete is offline Offline
147 posts
since Dec 2005
Dec 20th, 2005
0

Re: file open code in VB

Quote originally posted by complete ...
How does one create the process where a user can open (select) a file to read from? In C++ there are already classes to inherit from. Do I have to make a file open form from scratch in VB?
Quote ...
So far, the programs you have created have stored data in the computer’s memory in the form of variables. Memory is only a temporary storage while the computer is turned on and a program is running. A file is a collection of related data stored on a persistent medium such as a hard drive, a CD, or a diskette. (Persistent simply means lasting.) A file is different from a program and can be read from and written to by more than one program. Files are often used to provide data to a program. They are identified by the computer’s operating system with filenames assigned by the user.

There are three common data types:
• Sequential access files
• Direct access files
• Database files


Sequential file

• contains only plain text (i.e., text contains only ANSI ( American National Standards
Institute) text characters and the newline character, which is a carriage return-linefeed)
• can be prepared by NotePad or WordPad, but must be saved as text file
• data records must be input (read) one character at a time, in the same order that they were
placed on the file. (This is why it is called sequential.)
• each file ends with an EOF (end of file) marker
• Open, Input &Write
� Open “filename� For mode As #filenumber
 filename is the name of the file to be opened including its full path
 mode is either Input for reading the contents of the file or Output or Append for writing text to a file
 filenumber is a number, between 1 and 511, used to refer to the file
e.g., Open “a:\SumData.txt� For Input As #10
ï?± Input #n, list of variables (to input/read data from the file once it is opened)
Must be a one-to-one match (in terms of number and data type) between the list of variables and the data on the file
e.g., Input #10 houseNumber
Input #10 street
� Open “filename� for Output As #n
e.g., Open “a:\SumData.txt� for Output as #1
ï?± Write #n, list of variables (to output/write data on the file once it is opened)
• Close statement (use the statement when the program is terminated)
Close #n e.g., Close #10
Quote ...
Dim name As string, wage as single, hours as single
dim pay as currency

picPay.cls

open"staff.txt" for input as #1 'open data file
input #1, name, wage, hrs ' read in first employee's record
pay = wage * hrs 'calculate pay
picPay.print name, format(pay, "currency")
input #1, name, wage, hrs 'read in second employee's record
pay = wage * hrs 'calculate pay
picPay.Print name, format(pay, "currency")
Close #1
i just quickly typed this up just to show you an example

there's another complicated one that i could show you-- but i want to watch some anime DX ... kthxbai

XD
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chopaface is offline Offline
3 posts
since Dec 2005
Dec 20th, 2005
0

Re: file open code in VB

I have seen some sample code in VB which shows some methods of opening and reading from a file.

But what about the GUI side of things? When the user runs the program, I want him/her to be able to select which file he/she wants to be read. Do I have to make these froms from scratch ? Are there already pre-existing windows commands I can use in my VB program which I can call and will handle the user interface where the user will pick the desired file?
Reputation Points: 17
Solved Threads: 0
Junior Poster
complete is offline Offline
147 posts
since Dec 2005
Dec 20th, 2005
0

Re: file open code in VB

well eventually-- u'd hav to make it by scratch if u cant find the approriate codings for it-- if u need help, consult with a vb guide book--

wait do u mean thpose tab commands? (ie file, edit, help...)?
n that if u select open, u can open the file that picked?

those r ez
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chopaface is offline Offline
3 posts
since Dec 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Opening a copy of Outlook
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: I need help





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC