The document discusses how breaking programs down into sections or subprograms makes them easier to read, understand and manage. It provides examples of how to structure a program using subprograms and parameters to pass information between the subprograms. Key aspects covered include declaring global and local variables, using subprograms to perform main steps, and using parameters and CASE statements to control program flow and data passing between subprograms.
This book's author is Zafar Ali Khan .
It consists of all the topics of As Level Computer Science topics that are required to be covered.
All credits goes to Zafar Ali Khan .
Computer programming:Know How to FlowchartAngelo Tomboc
This topic guides you how to flowchart...What are the symbols. Some mathematical symbols are included to especially equal,more than, less than, not equal, more than or equal to, and less than or equal to. Flowcharting...what is that???Flowcharting is just a building house using your bricks, tools in carpenter, and a blueprint...So, [G]LHF ([G]OOD LUCK HAVE FUN) ^_^
This book's author is Zafar Ali Khan .
It consists of all the topics of As Level Computer Science topics that are required to be covered.
All credits goes to Zafar Ali Khan .
Computer programming:Know How to FlowchartAngelo Tomboc
This topic guides you how to flowchart...What are the symbols. Some mathematical symbols are included to especially equal,more than, less than, not equal, more than or equal to, and less than or equal to. Flowcharting...what is that???Flowcharting is just a building house using your bricks, tools in carpenter, and a blueprint...So, [G]LHF ([G]OOD LUCK HAVE FUN) ^_^
Program Slicing is a technique used by programmers or testers
in order to debug, understand or analyze a coded program. In
this paper, I summarize three different types of program slicing
explaining concepts, slicing algorithms, and giving some examples
based on three different published papers. Those different types of
slicing are: Static slicing, Thin Slicing, and Dynamic Slicing.
After that, I compare all the three approaches of slicing to each
other in terms of accuracy of finding the buggy statements and
which type is more efficient and some other aspects.
Keywords: Static Slicing - Thin Slicing - Dynamic Slicing -
Debugging - Slicing algorithm.
Intro To C++ - Class 11 - Converting between types, formatting floating point...Blue Elephant Consulting
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
Program Slicing is a technique used by programmers or testers
in order to debug, understand or analyze a coded program. In
this paper, I summarize three different types of program slicing
explaining concepts, slicing algorithms, and giving some examples
based on three different published papers. Those different types of
slicing are: Static slicing, Thin Slicing, and Dynamic Slicing.
After that, I compare all the three approaches of slicing to each
other in terms of accuracy of finding the buggy statements and
which type is more efficient and some other aspects.
Keywords: Static Slicing - Thin Slicing - Dynamic Slicing -
Debugging - Slicing algorithm.
Intro To C++ - Class 11 - Converting between types, formatting floating point...Blue Elephant Consulting
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
This presentation is a part of the COP2272C college level course taught at the Florida Polytechnic University located in Lakeland Florida. The purpose of this course is to introduce students to the C++ language and the fundamentals of object orientated programming..
The course is one semester in length and meets for 2 hours twice a week. The Instructor is Dr. Jim Anderson.
Cis 1403 lab1- the process of programmingHamad Odhabi
This lab aims to develop students knowledge and skills needed to create a simple programming code. It covers the process of developing computer programs starting from a simple analysis of the problem, identifying outputs, inputs, and design process/algorithm, convert algorithm to code, testing, and documentation. The student will be introduced to the Java program structure, numerical variable and high-level introduction to data types. The lab does not go into depth explaining the data types and memory storage. These will be discussed in the upcoming labs. Also, the student will be introduced to the REPL cloud environment that will be used to create a simple application.
Learn Programming with Livecoding.tv http://goo.gl/tIgO1Ilivecoding.tv
If you want to learn programming, Livecoding.tv is a perfect platform to learn with the help of live-streams. Interact with expert coder on live chat and enrich your skills.
Come and join us
to see our streamers schedule please click on this link, http://goo.gl/tIgO1I
For most programming/scripting languages the concepts are all the same. The only thing that changes is the syntax in which it is written. Some languages may be easier to remember than others, but if you follow the basic guide line, it will make learning any programming language easier. This is in no way supposed to teach you everything about programming, just a general knowledge so when you do program you will understand what you are doing a little bit better.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Albert Hoitingh
In this session I delve into the encryption technology used in Microsoft 365 and Microsoft Purview. Including the concepts of Customer Key and Double Key Encryption.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
Monitoring Java Application Security with JDK Tools and JFR Events
Visual Basic
1. It is easier to read, understand and manage things if they are broken down into sections. Books are divided into chapters, essays are written in paragraphs, school subjects are split into units, school years are split into register classes. All of these things have been broken down into manageable ‘chunks’. Each ‘chunk’ has something in common. The chapter in a book is one part of the story. The unit at school is all on one topic. One register class all have the same guidance teacher, may all take German or all play in the school wind band. There is usually a list at the start of things to show what each of the ‘chunks’ are. The contents page at the beginning of a book, a course description of a subject at school or a list of register classes. Procedures & Parameters Sub-programs make your program more readable , maintainable, modular and robust . The same applies to programming. It is much easier to read, understand and manage a program if it is broken down into sections. Each section should perform a main step from your design. These sections are often known as procedures . In Visual Basic a procedure is called a sub-program When you write out the pseudocode for your program design then the main steps listed will each become sub-programs. At the beginning of your program, after you have listed the variables you will use, you will have to list the sub-programs you will use as well.
2. For Example… This would be written in code as: It’s worth remembering that the order you list the sub-programs in is the order they will run in. Private Sub cmdCalculate_click() DIM number1 as integer DIM number2 as integer DIM answer as integer Call get_numbers Call calculate Call display_result END Sub Variable statements Sub-program statements Pseudocode Sub-program name Main Steps 1. Get two numbers get_numbers 2. Calculate the sum calculate 3. Display the answer in message box Display_result
3. Private Sub cmdCalculate_click() DIM number1 as integer DIM number2 as integer DIM answer as integer Call get_numbers( ) Call calculate( ) Call Display_result( ) END Sub Sub get_numbers ( ) Number1 = InputBox(“Enter the first number”) Number2 = InputBox(“Enter the second number”) End Sub Sub calculate ( ) Answer = number1+number2 End Sub Sub Display_result( ) txtAnswer.text = answer End Sub So a whole program written with sub-programs would look something like this: Variable statements Sub-program get_numbers Sub-program calculate Sub-program display_result Sub-program statements
4. Private Sub cmdCalculate_click( ) DIM number1 as integer DIM number2 as integer DIM answer as integer Sub Display_result( ) txtAnswer.text = answer End Sub Sub calculate ( ) Answer = number1+number2 End Sub Sub get_numbers ( ) Number1 = InputBox(“Enter the first number”) Number2 = InputBox(“Enter the second number”) End Sub END Sub Call Display_result( ) Call calculate( ) Call get_numbers( ) Running order of a program which uses sub-programs
5. There are two different ways you can use variables within your program. Global Variables and Local Variables Variables Global Variables Global variables are variables whose value is available throughout your program for use by different sub programs. Global variables are declared right at the beginning of your program, before you call any sub programs. It is NOT good programming practise to make all your variables global. Global variables are more likely to be altered by mistake and produce errors in your code. Where possible, Local variables should be used. It will always be necessary to have some global variables as you will normally want to move some data between different sub programs, for example a value taken in in one sub program might be used in a calculation in another and displayed in a third.
6. Local Variables Local variables are variables which are used in only one sub program. They are not declared at the beginning of your code – instead the dimensioning takes place within the sub program. The value stored in a local variable can only be changed, used and viewed in the sub routine it was declared in. You should try to use Local variables whenever possible as it reduces the chances of values being changed by accident elsewhere in your code and makes the program easier to maintain and update. It is also considered good programming practise to use Local variables where possible.
7. Global Variable number Dimensioned at the start of the program Used in different sub programs – the value from one is passed into and used in the other Local variables counter and answer dimensioned within the sub program and used only in that sub program Local and Global variables
8. Sub-Programs & Parameters You can’t use sub-programs in Visual Basic without also using parameters . Parameters handle the flow of data within your program for all global variables. A parameter can be either a variable or a value . Parameters can be passed into and out of a sub-program. Parameters improve the reliability and robustness of your program You must list all the parameters you intend to use in each sub- program. This list must be included as part of the CALL statement and as part of the actual sub-program.
9. There are two different ways to pass parameters between sub-programs. You can pass parameters by VALUE or you can pass parameters by REFERENCE Passing Parameters Passing Parameters by Value Parameter Passing by VALUE is when a value is passed into a subprogram for use by the subprogram, but the changed value is not passed out. Parameters passed by Value are indicated by putting brackets around the parameter name. Passing Parameters by Reference Parameter Passing by REFERENCE is when a value is passed into a subprogram for use by the subprogram, and then the changed value is passed out to be used by other sub-programs. Parameters are passed by Reference by default and are simply listed in the parameter list.
10. Private Sub cmdBegin_Click() Dim number1 As Integer Dim number2 As Integer Dim answer As Integer Call get_numbers (number1, number2) Call calculate ((number1), (number2), answer) Call display_answer ((answer)) End Sub Sub get_numbers (number1, number2) number1 = InputBox("Enter number 1") number2 = InputBox("Enter number 2") End Sub Sub calculate (number1, number2, answer) answer = number1 + number2 End Sub Sub display_answer (answer) txtAnswer.Text = answer End Sub Example Comments The parameters are shown in blue number1 and number2 are changed in the get_numbers sub-program and the changed data needs to be used elsewhere so are passed by reference . The same parameters are listed here in the exact same order they are listed in the main program. number1 and number2 are simply passed into the calculate sub-program but are not changed and so are passed by value , answer is changed and needs to be passed by reference . answer is passed into the display_answer sub-program but is not changed and so is passed by value .
11. Sub-programs and parameters make designing your program even more crucial. You need to indicate in your design where and how parameters will be used. This could be by adding data flows to structure diagrams Or by indicating data flow in pseudocode. number1 number2 number1 number2 answer answer 1. Set up variables 2. Get numbers OUT: number1, number2 3. Calculate answer IN: number1, number2. OUT: answer 4. Display answer IN: answer 5. End Design Calculate Display answer Get Numbers Main
13. IF register_class = “4A” OR register_teacher = “4I” OR register_teacher = “5A” THEN guidance_teacher = “Ms Graham” Else IF register_teacher = “4B” OR register_teacher = “4G” OR register_teacher = “5C” THEN guidance_teacher = “Miss Stott” Else IF register_teacher = “4C” OR register_teacher = “4K” OR register_teacher = “5E” THEN guidance teacher = “Mrs Skellern” … (and so on) END IF IF register_class = “4A” THEN guidance_teacher = “Ms Graham” Else IF register_teacher = “4B” THEN guidance_teacher = “Miss Stott” Else IF register_teacher = “4C” THEN guidance teacher = “Mrs Skellern” … (and so on) END IF Using the CASE statement A CASE statement is a more efficient way of performing a multiple choice in programming. You could use the IF… THEN… ELSE IF… ELSE IF… ELSE IF … but it gets quite messy and you have to repeat the condition of the choice each time. For Example: The IF method gets even more messy if you have multiple possibilities giving the same result. For Example:
14. SELECT CASE register_ class CASE IS “4A”,”4I”,”5A” guidance_teacher = “Ms Graham” CASE IS “4B”, ”4G”,”5C” guidance_teacher = “Miss Stott” CASE IS “4C”, “4K”, “5E” guidance_teacher = “Mrs Skellern” END SELECT The CASE statement will perform this same task much more neatly and efficiently. SELECT CASE register_ class Case Is “4A”,”4I”,”5A” guidance_teacher = “Ms Graham” Case Is “4B”, ”4G”,”5C” guidance_teacher = “Miss Stott” Case Is “4C”, “4K”, “5E” guidance_teacher = “Mrs Skellern” End Select This is the variable you are checking This is the first condition (or conditions) to check if it meets. The comma means OR. This is what happens if the condition is met. There can be more than one line of code here.
15. The CASE statement treats number ranges differently from other Visual Basic structures. The default for a CASE condition is CASE IS. So CASE IS can be exactly something or more or less than one number. You cannot have a number range – CASE IS >20 AND <40 . If you need a number range you need to use CASE…..TO – CASE 20 TO 40
16. When using random numbers you need to use the RND command. Randomize is the word used to mix up a list of numbers each time a program is run. It is a pre-defined function . The value of the random number is between 0 and 1 (a real number or a fraction). If we want a bigger number we have to multiply the random number by the biggest amount we want. To see how random numbers work, look at the following program: Create random number Display random number Output Random Numbers
17.
18. Validation and Conditional Loops You need to remember to validate the input to any program. This will greatly reduce run-time errors caused by unexpected data and will also assist the users to enter the right data and be clear what they are doing. It will also help the testing phase. A simple validation could be something like entering a price which is less than £10. Private Sub cmdBegin_Click() DIM cost as Integer Cost = INPUTBOX(“Please enter the cost”) txtCost.text = cost END SUB Private Sub cmdBegin_Click() DIM cost as Integer DO Cost = INPUTBOX (“Please enter the cost”) LOOP UNTIL cost < 10 txtCost.text = cost END SUB No validation – you can enter what you like Simple validation Keeps asking until you enter a valid number – no error message If you wanted to make sure the cost of an item was less that £10 you would need to keep asking the user to enter the cost UNTIL it was less than £10. They might enter it correctly the first time, in which case they don’t need to be asked again or they might get it wrong one hundred times in which case the program will loop until they enter a cost that is less than £10. The problem here is that there is no message to tell the user why they keep getting asked for the same thing. You can add a condition which will check if the input is ok and print a helpful error message if it is not. This program will ask the user to enter the cost of an item and will display it in a text box. However, there is no way to check whether the cost is less than £10. To check this (this is called VALIDATION) you will need to use a conditional loop. A conditional loop is where some lines of code in your program will repeat until a certain condition is met.
19. Private Sub cmdBegin_Click() DIM cost as Integer DO Cost = INPUTBOX (“Please enter the cost”) IF cost >=10 THEN MSGBOX(“The cost must be less than £10”) END IF LOOP UNTIL cost < 10 txtCost.text = cost END SUB Private Sub cmdBegin_Click() DIM cost as Integer DO Cost = INPUTBOX (“Please enter the cost”) IF cost >=10 THEN MSGBOX(“The cost must be less than £10”) END IF LOOP UNTIL cost > 0 AND cost < 10 txtCost.text = cost END SUB This is better, every time an invalid cost is entered a message is displayed stating why and asking for the data again. This is correct – as it is a cost it also checks the number is greater than 0. The error message is still displayed and there is no chance the data entered will be inappropriate. It is much more difficult to validate text input, you can help eliminate problems by converting all text input to either upper or lower case, as Visual Basic considers them as different in a comparison - “john” would be considered as different from “John”. It is not always appropriate to convert all text to upper or lowercase. You can also count the number of characters entered – this can help with things like postcodes which are a fixed length.
20. So far all the variables you have used have been single item variables. As you write more complex programs you will find you need many similar variables in one program. If you were going to read in 10 pupils marks you could have 10 individual variables. Dim mark1 as integer Dim mark2 as integer Dim mark3 as integer Dim mark4 as integer Dim mark5 as integer Dim mark6 as integer Dim mark7 as integer Dim mark8 as integer Dim mark9 as integer Dim mark10 as integer This would also require 10 input statements Mark1 = inputbox(“Please enter Mark 1”) Mark2 = inputbox(“Please enter Mark 2”) Mark3 = inputbox(“Please enter Mark 3”) Mark4 = inputbox(“Please enter Mark 4”) Mark5 = inputbox(“Please enter Mark 5”) Mark6 = inputbox(“Please enter Mark 6”) Mark7 = inputbox(“Please enter Mark 7”) Mark8 = inputbox(“Please enter Mark 8”) Mark9 = inputbox(“Please enter Mark 9”) Mark10 = inputbox(“Please enter Mark 10”) This would require 10 variables txtMark1.text = mark1 txtMark2.text = mark2 txtMark3.text = mark3 txtMark4.text = mark4 txtMark5.text = mark5 txtMark6.text = mark6 txtMark7.text = mark7 txtMark8.text = mark8 txtMark9.text = mark9 txtMark10.text = mark10 And 10 output statements This is obviously an awful lot of repetitive code. There is a much better way of storing and using data which is related. This is using an array. Using Arrays
21. An array stores a number of variables in a special data structure. If you wanted to store a large amount of one type of data then you could use an array . An array to holds them all together and treats them as one thing . The program can then refer to the whole array or any single element of the array. You would declare an array like this: Array name The number of elements in the array Array data type DIM mark(10) as Integer The memory sets aside an area divided into elements Mark 1 2 3 4 5 6 7 8 9 10 So this element is referred to as Mark(6) and this one is Mark (8) An input statement would look like this: Mark(3) = Inputbox(“Please enter mark 3) The data entered would be placed in the third element of the array.
22. To eliminate the need for multiple INPUT and OUTPUT statements you would use a FOR loop for array operations. FOR counter = 1 TO 10 Mark( counter ) = Inputbox(“Please enter the mark “) NEXT counter FOR giraffe = 1 TO 10 lstResults.additem Mark( giraffe ) NEXT counter Whatever variable is used in the FOR loop is also used for the element position in the Array. As the loop goes round, the loop variable (counter or giraffe above) is incremented (goes up by one) so first time round counter = 1 and the input goes in Mark(1), next time round counter = 2 so the input goes in Mark(2) and so on. Instead of 10 input statements or 10 output statements, those three lines of code will input or output all 10 data items.
23. You can also use FOR loops and arrays to take in more than one set of related data. For example if you wanted to read in 6 student names and their marks. You need to keep the names and marks separate because you might want to use the numeric data for comparisons or calculations. You will need to declare 2 arrays one for names and one for marks. You will only need one FOR loop. Name Mark Jim 37 Bob 26 Sue 52 Jan 86 John 17 Peter 79 37 26 52 86 17 79 Jim Bob Sue Jan John Peter Name Mark (1) (2) (3) (4) (5) (6) (1) (2) (3) (4) (5) (6) So this data Would be stored like this This means that the name and mark are stored in different arrays but in the same position, so could be accessed at the same time using one FOR loop
24. DIM name(6) as String DIM mark(6) as Integer DIM pupil as Integer DIM result as Integer FOR pupil = 1 TO 6 name( pupil ) = Inputbox(“Please enter the name”) mark( pupil ) = Inputbox (“please enter the mark”) NEXT pupil FOR result = 1 TO 6 lstClassResults.additem name( result ) & “ “ & mark( result ) NEXT result This code uses one FOR loop to read in both the name and the mark. A different FOR loop is used to display the data in a list box.
25. String Operations Visual Basic considers upper and lower case text to be different, so if you had a quiz program where the answer should be true and the user entered TRUE, when you perform the comparison to see if they got the answer right the program would say they got it wrong. You can convert string data to upper and lower case to help prevent problems like this. To convert test to upper case or lower case you would use the UCase or LCase functions. lowercase_string = LCase(string_variable) uppercase_string = UCase(string_variable) Where string_variable is the original data and lowercase_string and uppercase_string is where the converted data is stored. You can use the Len function to find out how many characters are in a string variable. It counts spaces as well as characters. You will need to store the length as a numeric variable. Numeric_variable = Len(string_variable) If string_variable = “John Smith” then numeric_variable = 10 If string_variable = “Hello” then numeric_variable = 5
26. One of the operations you can do with string variables is string concatenation – this is adding the two strings together. It is as simple as this: Newstring = string1+string2 DIM initial as String DIM surname as String DIM userID as String initial = Inputbox(“Please enter your initial”) surname = Inputbox(“Please enter your surname”) userID = surname+initial INPUT : initial = V surname = Mackenzie OUTPUT : MackenzieV String Operations - Concatenation
27. String Operations – Sub String A Sub string operation is where you separate part of the string value. You can take the first character, the middle three characters, the last two, the first seven. Basically you can separate whatever number of characters you want from wherever you want in the string. You need to use the Mid$ function for this: String_output = Mid$(string_input, start position, number or characters) String_out = Mid$(string_input, 2, 3 ) So if string_input = “Greetings” Then String_out = “ree” If string_input = “Computing is Fun” Then String_out = “omp” Character to start at How many characters to extract