Public Class Form1 Const MAXSIZE As Integer = 50 Dim Zeki(MAXSIZE) As Integer Dim Ozzy(MAXSIZE) As Integer Dim Ozyilmaz(MAXSIZE) As Integer Dim i As Integer 'Accounts for the difference from the 2008 version where you do not _ ' have to declare i as integer when using it in a "For_next function '------------- Problem number 1------------ Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load countZeki() 'fill in the arrays when program is loaded countOzzy() ' countOzyilmaz() End Sub Private Sub BFill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BFill.Click 'fills in the original values for arrays countZeki() countOzzy() countOzyilmaz() End Sub Sub countZeki() 'Puts into array numbers 1 - 50 For i = 1 To MAXSIZE Zeki(i) = i Next End Sub Sub countOzzy() ' puts into array even, first 50 even numbers from 1 For i = 1 To MAXSIZE Ozzy(i) = i * 2 Next End Sub Sub countOzyilmaz() ' puts into array odd, first 50 odd numbers from 1 For i = 1 To MAXSIZE Ozyilmaz(i) = (i * 2) - 1 Next End Sub '------------ Problem number 2 --------------- Private Sub BShowZeki_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BShowZeki.Click 'Displays in output the values of array Zeki outputzeki() End Sub Private Sub BShowOzzy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BShowOzzy.Click 'Displays in output the values of array Ozzy outputozzy() End Sub Private Sub BShowOzyil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BShowOzyil.Click 'Displays in output the values of array Ozyilmaz outputOzyil() End Sub Sub outputzeki() Dim total As Integer total = totalzeki() With LOutput.Items .Clear() For i = 1 To MAXSIZE If 0 = Zeki(i) Then Else .Add(Zeki(i)) End If Next .Add("The total of all of these added is " & total) End With End Sub Function totalzeki() Dim total As Integer For i = 1 To MAXSIZE total += Zeki(i) Next Return total End Function Sub outputozzy() With LOutput.Items .Clear() For i = 1 To MAXSIZE .Add(Ozzy(i)) Next End With End Sub Sub outputOzyil() With LOutput.Items .Clear() For i = 1 To MAXSIZE .Add(Ozyilmaz(i)) Next End With End Sub '---------Problem number 3------------- Private Sub BDiv3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BDiv3.Click 'will zero out any values in the first array that are divisible by 3 div3() End Sub Private Sub Bdiv5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bdiv5.Click 'will zero out any values in the first array that are divisible by 5 div5() End Sub Private Sub BDiv7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BDiv7.Click 'will zero out any values in the first array that are divisible by 7 div7() End Sub Sub div3() For i = 1 To MAXSIZE 'Divides array(i) by 3 and finds the remainder If 0 = Zeki(i) Mod 3 Then Zeki(i) = 0 End If Next End Sub Sub div5() For i = 1 To MAXSIZE 'Divides array(i) by 5 and finds the remainder If 0 = Zeki(i) Mod 5 Then Zeki(i) = 0 End If Next End Sub Sub div7() For i = 1 To MAXSIZE 'Divides array(i) by 57 and finds the remainder If 0 = Zeki(i) Mod 7 Then Zeki(i) = 0 End If Next End Sub '--------------Problem Number Four---------------- Private Sub BCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BCheck.Click ' obtain an integer value from the textbox, and finds numbers that are bigger, smaller and divisible by the input Dim x, bigger, smaller, divis As Integer x = getx() bigger = findbigger(x) smaller = findsmaller(x) divis = finddivis(x) outputcount(bigger, smaller, divis, x) End Sub Function getx() 'gets the input from the textbox Dim x As Integer = TInput.Text Return x End Function Function findbigger(ByVal x As Integer) Dim count As Integer 'finds out what numbers are SMALLER then the inputed number For i = 1 To MAXSIZE If Zeki(i) < x Then count += 1 End If Next Return count End Function Function findsmaller(ByVal x As Integer) Dim count As Integer 'finds out what numbers are BIGGER then the inputed number For i = 1 To MAXSIZE If Zeki(i) > x Then count += 1 End If Next Return count End Function Function finddivis(ByVal x As Integer) Dim count As Integer 'finds out what numbers are DIVISIBLE by the number For i = 1 To MAXSIZE If 0 = Zeki(i) Mod x Then count += 1 End If Next Return count End Function Sub outputcount(ByVal bigger As Integer, ByVal smaller As Integer, ByVal divis As Integer, ByVal x As Integer) With LOutput.Items 'outputs the counts .Clear() .Add(bigger & " numbers are smaller then " & x) .Add(smaller & " numbers are bigger then " & x) .Add(divis & " numbers are divisible by " & x) End With End Sub '--------Problem number five -------- 'uses getx function from problem 4 Private Sub BSums_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BSums.Click ' obtain an integer value from the textbox, and finds numbers that are bigger, smaller and divisible by the input Dim x, total, greattotal, divistotal As Integer x = getx() total = calczeki() greattotal = calcgreattotal(total, x) divistotal = calcdivistotal(total, x) outputsum(x, total, greattotal, divistotal) End Sub Function calczeki() 'calcs the sum total of all values in the first array Dim total As Integer For i = 1 To MAXSIZE total += Zeki(i) Next Return total End Function Function calcgreattotal(ByVal total As Integer, ByVal x As Integer) Dim gtotal As Integer 'calcs the total of the numbers greater then the input and returns it For i = 1 To MAXSIZE If Zeki(i) > x Then gtotal += Zeki(i) End If Next Return gtotal End Function Function calcdivistotal(ByVal total As Integer, ByVal x As Integer) Dim dtotal As Integer 'calcs the total of the numbers divisible by the input and returns it For i = 1 To MAXSIZE If 0 = Zeki(i) Mod x Then dtotal += Zeki(i) End If Next Return dtotal End Function Sub outputsum(ByVal x As Integer, ByVal total As Integer, ByVal greattotal As Integer, ByVal divistotal As Integer) With LOutput.Items 'outputs the counts .Clear() .Add(total & " is the total of adding up all of Zeki()") .Add(greattotal & " is the total of the numbers that are bigger then " & x & " added up") .Add(divistotal & " is the total of numbers that are divisible by " & x & " added up") End With End Sub '-----------Problem number 6 ---------------------- '---Couldnt get to problem 6 'EXTRA CREDIT!!! 'Extra a Private Sub Ba_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ba.Click calca() 'adds 1st array to the 2nd array End Sub Sub calca() 'adds 1st array to the 2nd array For i = 1 To MAXSIZE Ozzy(i) = (Zeki(i) + Ozzy(i)) Next End Sub End Class