0% found this document useful (0 votes)
43 views22 pages

14 EDP Strings Arrays

The document discusses event driven programming in Spring 2019 and covers various array concepts and examples in Visual Basic .NET, including: 1) The InStr method can be used to check for the presence of a character like '@' in a string like an email address. 2) Arrays allow grouping of related variables of the same type under one name. Examples include names of cities or employee records. 3) Various examples demonstrate storing values in arrays, iterating through arrays to display or calculate values like sums, and sorting arrays in ascending order by accepting user input.

Uploaded by

nasir shahab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views22 pages

14 EDP Strings Arrays

The document discusses event driven programming in Spring 2019 and covers various array concepts and examples in Visual Basic .NET, including: 1) The InStr method can be used to check for the presence of a character like '@' in a string like an email address. 2) Arrays allow grouping of related variables of the same type under one name. Examples include names of cities or employee records. 3) Various examples demonstrate storing values in arrays, iterating through arrays to display or calculate values like sums, and sorting arrays in ascending order by accepting user input.

Uploaded by

nasir shahab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

EVENT DRIVEN

PROGRAMMING
Spring 2019
2nd April, 2019
String Position
• InStr method
• InStr() gives the position of one string within the other
InStr
• If you have a form to collect user information and there
is a field for user email address
• Need to make sure that email address is valid
• To check validity, you must ensure that there is at least
one @ character within the address
Using InStr() method
Output of InStr()
Arrays
An Array
• An array is a group of variables that have the same name
and data type and are related
• Examples
• Names of cities
• Employee records
• Marks of all students in EDP
• An array is a set of consecutive memory locations under
one name
An Array: consecutive memory locations
Example1

Dim num() As Integer = {11, 22, 33, 44, 55, 66}


Dim i As Integer
For i = 0 To 5
ListBox1.Items.Add(num(i))
Next i
Example2
Dim num() As Integer = {11, 22, 33, 44, 55, 66}
Dim sum As Integer
Dim i As Integer
For i = 0 To 5
sum = sum + num(i)
ListBox1.Items.Add(num(i))
Next i
MessageBox.Show(sum)
Sum displayed
Example3
Dim num(5) As Integer
Dim i As Integer
Dim sum As Integer
For i = 0 To 5
num(i) = i
sum = sum + num(i)
Next
MsgBox(sum)
Sum displayed
Example4
Dim num(5) As Integer
Dim i As Integer
Dim sum As Integer
For i = 0 To 5
num(i) = i + 5
sum = sum + num(i)
Next i
MessageBox.Show(sum, "Sum Value")
Sum Displayed
Example5
Dim num(5) As Integer
Dim i As Integer
Dim sum As Integer
For i = 0 To 5
num(i) = num(i) + i + 2
sum = sum + num(i)
Next i
MessageBox.Show(sum, "Sum Value")
Sum displayed
Task1
• Write click event to store numbers 10, 20, 30, 40,
50,60,70,80,90,100 using some expression (formula).
• Your code should then display the array in reverse order
Solution – task1
Task2
• Write click event to sort an integer array in ascending
order.
• Enter array values by accepting input from the user (use
Inputbox)
• Size of array is 10

Solution task 2
http://www.worldbestlearningcenter.com/index_files/vb.net-example-selection-sort.htm

You might also like