| | |
file open code in VB
![]() |
•
•
Join Date: Dec 2005
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
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
there's another complicated one that i could show you-- but i want to watch some anime DX ... kthxbai
XD
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?
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?
![]() |
Similar Threads
- How a doc file can be open inside browser without prompting the download dialog box (ASP.NET)
- How to open multiple textfile (Visual Basic 4 / 5 / 6)
- file open dialog box control in asp.net (ASP.NET)
- C language (C++)
- Check the code!! (C++)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: Opening a copy of Outlook
- Next Thread: I need help
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





