Application Programming for Information Systems
Application Programming for Information Systems IST 256
Popular in Course
Popular in Information Studies
This 18 page Class Notes was uploaded by Reese Schmeler on Wednesday October 21, 2015. The Class Notes belongs to IST 256 at Syracuse University taught by Nancy McCracken in Fall. Since its upload, it has received 35 views. For similar materials see /class/225670/ist-256-syracuse-university in Information Studies at Syracuse University.
Reviews for Application Programming for Information Systems
Report this Material
What is Karma?
Karma is the currency of StudySoup.
You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!
Date Created: 10/21/15
Selection Decision Structures Many times in programming you want to make a decision based on the values of the variables and select different courses of action based on that If Statements The first type of decision structure allows the selection of either one or two alternatives based on a condition The one alternative version is the lf Then statement If the comparison is true then the statements in some action are executed If the comparison is false no actions are executed IF number or variable comparison number or variable THEN some action ENDIF Example If total gt 500 Then DiscountRate 10 End If The two alternative version is the lf Then Else statement If the comparison is true then the statements in some action are executed If the comparison is false then some different actions are executed IF number or variable comparison number or variable THEN some actions ELSE some different actions ENDIF Example If total gt 500 Then DiscountRate 10 E se DiscountRate 05 End If Comparison Operators S revenue Of 0 zero Select Case Statement This statement works for the situation Where you have a single variable and you want to make decisions based on the values of that variable The Select Case statement Will allow you to program alternatives for each value of the variable or for a range of values In the Select Case statement only one alternative is ever executed The first form of the select statement has alternative actions based on individual values of the variable Select Case ltvariable of any typegt Case ltvalue1gt some action 1 Case ltvalue2gt some action 2 Case ltvalueNgt some action N the else case is optional Case else some more action End Select If the value of the variable is valuel then the first some action is executed and all the rest are skipped If the value of the variable is value2 then the second some action is executed and all the rest are skipped If there is an else case and the value of the variable is not listed in any of the other cases then this action is executed Example Select Case grade Case quotAquot message quotGreatquot Case quotBquot message quotGoodquot Case quotCquot message quotOkay you made itquot Case quotDquot message quotNot so goodquot Case quotFquot message quotDisasterquot Case Else message quot quot End Select The second form of the select statement has alternative actions based on ranges of values of the variable Select Case ltvariable of any typegt Case ltvalue1gt to ltendvalue1gt some action 1 Case ltvalue2gt to ltendvalue2gt some action 2 Case ltvalueNgt to ltendvalueNgt some action N the else case is optional Case else some more action End Select In this form each alternative action is executed if the value of the variable falls Within the range of the two values given in the case Example Select Case gradeaverage Case 90 To 100 grade quotAquot Case 80 To 89 grade quotBquot Case 60 To 79 grade quotCquot Case 40 To 59 grade quotDquot Case Else grade quotFquot End Select Note that Select Case statements can also have a mix of value and value ranges in a single statement Radio Buttons and Check Boxes After you place a set of Radio Buttons or Check Boxes on a form the code to find out if one has been checked is the same If RadioButtonI checked If Checkboxlchecked You can also use something like If checkbox checked 2 true The difference between Radio Buttons and Check Boxes is that only one radio button can be checked at a time but any number of check boxes can be checked Memo Boxes Memo Boxes are good for writing multiple lines to the screen To set up a memo box you need to do the following Put one on the form gt Double click on the strings in the property lines By default the memo box only has 2 lines gt You must manually add lines by hitting the return key in the String List Editor Window that appears when you double click on the strings A line in a memo box is referenced as follows Memolinesx Where x is any integer or integer variable Memo boxes start at line 0 IST 256 Introduction to Application Programming WrapUp I Learning Outcomes 0 Progamming concepts learned in this course Design a user interface that is easily understood and used Write efficient and elegant computer programs that can be easily understood by a knowledgeable person Explain the three structures of structured programming and use them to solve complex problems 0 statements in sequence selection if select case loops Be able to efficiently manipulate constants simple variables one and two dimensional arrays and records Program a computer to perform simple mathematical functions string processing and manipulate input and output files Why take this course 0 Most important result is to learn critical thinking stepbystep analysis of problems 0 Companion course to IST 352 Information Analysis of Organizational Systems Information Analysis works with the overall design of the parts of the system and data ow analysis This course works with the details of one part of a system how to implement it and how data ows in and out of the system 0 our programs were also composed of parts modules event procedures other procedures and functions Programming skills in Visual Basic other languages can easily be learned as needed programming concepts are the same 0 Can appreciate issues of programmers and how programming fits into the solution of business problems 3 IST 256 Introduction to Application Programming WrapUp I Learning Outcomes 0 Programming concepts learned in this course Design a user interface that is easily understood and used Write efficient and elegant computer programs that can be easily understood by a knowledgeable person Explain the three structures of structured programming and use them to solve complex problems 0 statements in sequence selection if select case loops Be able to efficiently manipulate constants simple variables one and two dimensional arrays and records Program a computer to perform simple mathematical functions string processing and manipulate input and output files Why take this course Most important result is to learn critical thinking stepbystep analysis of problems Companion course to IST 352 Information Analysis of Organizational Systems Information Analysis works with the overall design of the parts of the system and data ow analysis This course works with the details of one part of a system how to implement it and how data ows in and out of the system 0 our programs were also composed of parts modules event procedures other procedures and functions Programming skills in Visual Basic other languages can easily be learned as needed programming concepts are the same Can appreciate issues of programmers and how programming fits into the solution of business or other information science problems 3 Constants and Variables Revised 128 Constants are used to hold values that never change at least for the life of the program Some constants truly are constant for example the value of pi is always 314 and the number of inches in a foot are always 12 At other times the same value will hold for the run of a program e g number of students tax rate etc Declaling constants looks like the following Const Pi as single 2 314 Const lnchperfoot as integer 12 Const Numstud as integer 40 Const Welcome as string 2 Welcome to the Superette Const Taxrate as single 2 007 Note that if you have a percent it must have a 0 in front of the decimal Variables are used to hold values that can change while a program is running There are three types of variables that we39re concerned with now integer for whole numbers single for numbers that can have a decimal string for strings of characters Declaring variables looks like the following Dim Age as integer Dim GPA as single Dim Student as string 30 note the number at the end it39s there to save space otherwise the computer will make the string 256 characters long Good programming practice requires that all variables be declared Visual Basic doesn t enforce this and as a result it is possible to create variables inadvertently For example you could misspell a variable name and by doing so you would have created another completely different variable To make sure this doesn t happen you can use Ogtion Explicit You must use this for all programs in this course Assignments In order to give a variable a value you assign a value to it The value could be a simple value or it could be the result of an expression The format is as follows Variable value Variable 2 expression The value may be one of a number of things An actual value IQ 115 The value of another variable YourIQ Mle The result of a computation YourIQ MyIQ 40 The value of a constant Length footlength where footlength was declared as 12 The result of a concatenation Welcome 2 Howdy amp amp Pardner Input and Output t0 Textboxes In order to get input values from the user interface you can get numbers or strings that the user types in to a textbox You can also output numbers and strings by assigning them to a textbox Using the textbox for values means that you will use the text property Suppose that you put a textbox on your user interface and that you put its name property to be txtNumber If the user types in a value it goes into the Text property and to get that value and convert it to an integer you say CInttxtNumberText Normally you may assign this value to a variable Dim firstnumber as integer firstnumber CInttxtNumberText Now the variable firstnumber will have the integer value that the user typed in There is a text conversion function for each data type CInt converts text to an integer CSng converts text to a single CStr converts text to a string if necessary You can also use the Text property to output a value to a Textbox For example txtNumberText Cstrintsum Records Record structures allow a number of data items to be grouped together and named These structures are useful as array elements to store a number of data items in memory that can be of different types As with arrays the data items may be input from a file or they may be created by a program Record Structures A record structure is first defined as a type in a Visual Basic class Private Structure ltrecordnamegt ltVariable declaration 1gt ltVariable declaration ngt End Structure The variables declared in the structure are the names of fields in the record structure Example Private Structure petrecord Dim petname owner species as String Dim weight As Single End Structure Setting and Using Fields of a Record Structure A regular variable can be declared to have the type of a record structure Dim pet As petrecord The fields are accessed by using a dot notation and the name of the field petpetname Fluffy petowner 2 Jay Jones petspecies 2 Domestic Orienta petweight 72 These values can be used in further computations such as If petweight gt 100 Then LabellTeXt 2 Large End If Declaration of arrays whose elements are fields A common use of record structures is as elements of arrays Dim ltarraynamegt 0 to ltmaxnumbergt as ltrecordtypegt Example Dim pets 0 to 24 as petrecord Now each element of the array can be accessed via array subscripting Since this element is a record structure then the dot notation is used to access individual elements Example assigning elements of the pet record in array location 0 Dim n as Integer 0 petsnpetname Fluffy petsnowner 2 Jay Jones petsnspecies 2 Domestic Orienta petsnweight 72 It is also quite common to get the values of an array of records from a file using the input command Suppose that you have a file With the elements of one pet record on each line Dim n as Integer 0 While Not EOF1 Input 1 petsnpetname Input 1 petsnowner Input 1 petsnspecies Input 1 petsnweight nn1 End While This Will read each pet record from the file and store it into the pets array With notation for record structures As an abbreviation for giving the name of the record structure variable With the dot notation for each field if you are doing a lot of dot notations on a single element the Wit notation allows an abbreviation This abbreviation allows you to omit the name of the record The goal of the abbreviation is just to save typing Dim n as Integer 0 While Not EOF1 With petsn Input 1 petname Input 1 owner Input 1 species Input 1 Weight End With nn1 End While Hierarchical Record Structures Record structures can be further organized by having an element of one record structure be another record structure This is a useful tool for organizing information Private Structure addressrecord Dim street city state zip as String End Structure Private Structure petrecord Dim petname owner species as String Dim weight As Single Dim address As addressrecord End Structure Setting and using elements of Hierarchical Records For each element of an inner record an additional dot notation is used to access the element For example the zip code of a single pet petaddresszip This additional notation can also be used in arrays of record structures Arithmetic Standard arithmetic such as addition and multiplying can be used in expression with either variables or constants For numbers addition subtraction and multiplication all use the same operator symbol for integers and singles Division uses a different operator for getting an integer result than a single If there is more than one operator in an expression then they are either evaluated in the order indicated by parentheses but if there are no parentheses exponents are evaluated first then multiplication and division and finally addition and subtraction For strings there is an operator to catenate two strings together For example in the following Stringl The Cat String2 in the Hat String3 Stringl amp amp String2 The value of String3 is The Cat in the Hat Counters and Accumulators Counters and accumulators are specific types of assignment statements that are used to perform a couple of very useful computations that involve adding numbers into a running total A classic use of counters and accumulators is for finding an average In order to get an average you must get a total of all the items as well as the number of items Counters Basically a counter counts It keeps track of how many times an event occurred Generally you will set the counter to 0 as the program opens and then every time a particular event occurs eg every time a button is pressed you add 1 to the counter The formats are very simple First define the variable dim num as integer To set it to zero num 0 To increment it num num I Accumulators Accumulators accumulate They keep a running total Generally you Will set the accumulator to 0 as the program opens and then every time a particular event occurs eg every time a button is pressed you add some number to it Again the formats are very simple First define the variable dim total as integer To set it to zero total 0 To increment it total total cost
Are you sure you want to buy this material for
You're already Subscribed!
Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'