Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
P1PMF Split1 QBASIC. P1PMF Split2QBasic Command Prompt Will launch the emulator DOS operating system? Press Alt + Enter to display the widescreen.
Advertisements

30/04/ Selection Nested If structures & Complex Multiple Conditions.
IS 1181 IS 118 Introduction to Development Tools VB Chapter 06.
The Initial Visual Basic Screen
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
Input Validation Check the values entered into a text box before beginning any calculations Validation is a form of ‘self-protection’, rejecting bad data.
To type the VB code behind the command button (named cmdPush), Double-Click on the Push Me (caption) command button As a result the Visual Basic Code Window.
Muffin Shop - if, calculations etc. (muffins, muffins2) Please use speaker notes for additional information!
3/9/2004 PPCC - Introduction to VB6 Copyright ©2004, Tore Bostrup 1 Introduction to VB6 Week 2.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
© 1999, by Que Education and Training, Chapter 5, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Vanche Gujarat Abhiyaan(VGA)- Best Reader Competition Online Student Registration and Data Entry presentation.
1 Visual Basic for Applications (VBA) for Excel Prof. Yitzchak Rosenthal.
InvEasy (Project1) Please use speaker notes for additional information!
Break Processing Please use speaker notes for additional information!
Array Processing: Exercises School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 10, Friday 3/28/2003)
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Chapter 7 Code Tables. VB Code Box 7-1 Event Procedure for Compute Button Private Sub hsbExemptions_Change() txtExemptions.Text =Str(hsbExemptions.Value)
Let’s get started using Visual Basic!. Private Sub cmdGo_Click... Dim strMessage As String Dim sngSum As Single If IsNumeric(txtNumber1.Text) = False.
Chapter 4: The Selection Process in Visual Basic.
Programming Examples to Accompany Structure Topic Please use speaker notes for additional information!
Copyright © 2001 by Wiley. All rights reserved. Chapter 5: The Repetition Process in Visual Basic Event Driven Loops Determinate Loops Indeterminate Loops.
Logic Structure - focus on looping Please use speaker notes for additional information!
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
Array - adding to array at run time Please see speaker notes for additional information!
Do Loop with Interest Please see speaker notes for additional information!
Chapter Six: Working With Arrays in Visual Basic.
New Project in Visual Basic Please use speaker notes for additional information!
Random Files Please see speaker notes for additional information!
Chapter 8 - Visual Basic Schneider
Delivery and other DO Examples Please use speaker notes for additional information!
Graphical User Interface You will be used to using programs that have a graphical user interface (GUI). So far you have been writing programs that have.
Notes on ADO from other projects Please use speaker notes for additional information!
Sequential files School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 12, Monday 4/07/2003)
Two Forms Please use speaker notes for additional information!
Copyright © 2001 by Wiley. All rights reserved. Chapter 6: Using Arrays Control Arrays List Arrays Finding Items in Arrays Multiple Forms 2-Dimensional.
VAT Calculator program Controls Properties Code Results.
Pay Example (PFirst98) Please use speaker notes for additional information!
In this activity, we are going to type a simple Chinese sentence with Microsoft Word by Tsang-jei Input Method and Simplified Tsang-jei Input Method. 1Start.
31/01/ Selection If selection construct.
CSC 162 Visual Basic I Programming. Repetition Structures Pretest Loop –Exit condition is tested before the body of code is executed Posttest Loop –Exit.
Visual Basic.net Functions. Function (Defined) A procedure that returns a value when called.
Tutorial 81 Field, Record, Data File Field - a single item of information about a person, place, or thing Record - a group of related fields that contain.
Using a Database Access97 Please use speaker notes for additional information!
An Overview of the Energy Reduction Calculator.  Calculates reduction in emissions for a facility Emissions computed are Carbon Dioxide, Sulfur Dioxide,
Knowledge Base. Defining a Variable Dim statement Dim intXX As Integer Public in a Module Public dblNN As Double.
Loop Blocks Chapter 6 Part A. Program Blocks 1.Actions- commands, messages, methods 2.Branches- decisions to be made 3.Loops- actions to be repeated.
I am using Visual Basic 6 for this class. If you want to use a different version, please contact me. Thanks!
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Subroutines (PrArith, Math,projCP1, PrAdrProc, PrAdrProcFunc) Please use speaker notes for additional information!
Problem: Take Two Numbers, Add Them Together And Display The Results. Now To Build The Flowchart… We Probably Need One Like This… Let’s Add The Routines…
Multiple forms - SDI & MDI Please use speaker notes for additional information!
Visual Basic - Break Processing
Processing multiple files
Visual Basic Fundamental Concepts
Find, filter etc with connection to Access code internally
Please use speaker notes for additional information!
Please use speaker notes for additional information!
Visual Basic..
Department Array in Visual Basic
Please use speaker notes for additional information!
I am opeing Access 2003 in the Microsoft Office.
Please use speaker notes for additional information!
If statements (Inven1, Inven2, Inven2a, Inven3, Inven3a)
Process Exchange Transactions Activity
Prepared By: Deborah Becker
More on If statements (Calculate, Calculate1, Calculate2)
Text / Serial / Sequential Files
Template for the portfolio.
Introduction to Computer Programming IT-104
Presentation transcript:

Visual Basic I/O Programs (ProjRead1, ProjRead2, ProjWrite1, ProjPay) Please use speaker notes for additional information!

ProjRead1

Private Sub Form_Load() Open "A:\StudentA" For Input As #1 End Sub When the form is loaded, the StudentA file will be opened as Input (meaning it can be read). It is opened as #1. If a second file was opened, it could be opened as #2.

ProjRead1 Private Sub cmdRead_Click() Dim IdNo As String, Name As String, Major As String, GPA As String, NumCr As String Dim Ans As String Input #1, IdNo, Name, Major, GPA, NumCr If IdNo = "999" Then Rem Ans = MsgBox("End of File Reached", vbOKOnly, "EOF") MsgBox "End of File Reached", vbOKOnly, "EOF" Rem END and Close here terminate the program Close #1 End Else txtIdNo.Text = IdNo txtName.Text = Name txtMajor.Text = Major txtGPA.Text = GPA txtNumCr.Text = NumCr End If End Sub In cmdRead, I define the fields on the file. In the example, I defined them as all string. Since the last two fields were numeric, I could also have defined that as Single and/or Integer as shown below. Dim IdNo As String, Name As String, Major As String, GPA As Single, NumCr As Integer Input #1 relates to the file that was opened For Input as #1. This statement refers to the fields by the names that were defined in the Dim statements above. IdNo is checked to see if it is 999. If it is, processing will end. If IdNo is not 999, the data from the input record is moved to the text boxes on the form.

The results of clicking Read are shown above. Only the first three records are shown. After the last record has been read, I pressed Read again. The record with Idno = 999 was read and this indicated that end of file had been reached. The message was displayed.

ProjRead2 Note that because I am testing for EOF(1) instead of IdNo=999, the 999 record will show. When I press Read with the 999 record on the screen, the EOF message is displayed. IF EOF(1) tests to see if end of file has been reached on the file opened as #1.

ProjWrite1

Private Sub Form_Load() Open "A:\PayX" For Output As #1 End Sub When the form is loaded, a file is opened for Output called PayX. The file is opened as #1 since it is the only file being used in the code. Private Sub cmdWrite_Click() Write #1, txtName.Text, txtPayHour.Text, txtHours.Text, txtExempt.Text, txtMarital.Text, txtPriorPay.Text End Sub When the Write button is clicked, the write command writes the data that was inputted into the text boxes on the form. Private Sub cmdExit_Click() Close #1 End End Sub When the Exit button is clicked, file #1 is closed and processing is ended. Private Sub cmdClear_Click() txtName.Text = "" txtPayHour.Text = "" txtHours.Text = "" txtExempt.Text = "" txtMarital.Text = "" txtPriorPay.Text = "" txtName.SetFocus End Sub When the Clear button is clicked, the data in the text boxes on the form is cleared out and the fields are set to null values with “”.

ProjWrite1

ProjPay When the form is loaded, not data is displayed. Clicking the Read button will display the record on the screen.

ProjPay

The last record has been displayed and the Read button is clicked. At that point the EOF message box is displayed.