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?
complete -2 Junior Poster
chopaface 0 Newbie Poster
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?
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
Dim name As string, wage as single, hours as single
dim pay as currencypicPay.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
complete -2 Junior Poster
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?
chopaface 0 Newbie Poster
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
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.