file open code in VB

Reply

Join Date: Dec 2005
Posts: 109
Reputation: complete is an unknown quantity at this point 
Solved Threads: 0
complete's Avatar
complete complete is offline Offline
Junior Poster

file open code in VB

 
0
  #1
Dec 20th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 3
Reputation: chopaface is an unknown quantity at this point 
Solved Threads: 0
chopaface chopaface is offline Offline
Newbie Poster

Re: file open code in VB

 
0
  #2
Dec 20th, 2005
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?
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 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
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 109
Reputation: complete is an unknown quantity at this point 
Solved Threads: 0
complete's Avatar
complete complete is offline Offline
Junior Poster

Re: file open code in VB

 
0
  #3
Dec 20th, 2005
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?
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 3
Reputation: chopaface is an unknown quantity at this point 
Solved Threads: 0
chopaface chopaface is offline Offline
Newbie Poster

Re: file open code in VB

 
0
  #4
Dec 20th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC