Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary VisualBasic Notes

Rating
-
Sold
-
Pages
19
Uploaded on
06-06-2023
Written in
2022/2023

The Document is about A-levels Computer Science paper 4 notes (codes) These codes will help you to ace your computer science paper 4 score. The codes are linked and consistent with alevels past papers with proper headings

Institution
Course

Content preview

Visual basic code p4
Linear searching using for loop
Sub linearsearch_for_loop()
Dim data() As Integer = {22, 66, 55, 88, 99}
Dim found As Boolean = False
Dim i, searchno, indexnum As Integer
searchno = Console.ReadLine
For i = 0 To data.Length - 1
If searchno = data(i) Then
found = True
indexnum = i
Exit For
End If
Next
If found = True Then
Console.WriteLine("number found at " & indexnum)
Else
Console.WriteLine("number not found")
End If
End Sub
Linear searching using While loop
Sub linearsearch_while_loop()
Dim data() As Integer = {22, 66, 55, 88, 99}
Dim found As Boolean = False
Dim i, searchno, indexnum As Integer
searchno = Console.ReadLine
i=0
While i <= data.Length - 1 And found = False
If searchno = data(i) Then
found = True
indexnum = i
End If

TAHA IQBAL

, i=i+1
End While
If found = True Then
Console.WriteLine("number found at " & indexnum)
Else
Console.WriteLine("number not found")
End If
End Sub
Linear searching using Repeat loop
Sub linearsearch_repeat_loop()
Dim data() As Integer = {22, 66, 55, 88, 99}
Dim found As Boolean = False
Dim i, searchno, indexnum As Integer
searchno = Console.ReadLine
i=0
Do
If searchno = data(i) Then
found = True
indexnum = i
End If
i=i+1
Loop Until (i > data.Length - 1 Or found = True)
If found = True Then
Console.WriteLine("number found at " & indexnum)
Else
Console.WriteLine("number not found")
End If
End Sub




TAHA IQBAL

, Bubble Sort(Efficient)
Sub BubbleSort()
Dim Temp As String
Dim NoSwaps As Boolean
Dim Boundary, J As Integer
Boundary = 8
Do
NoSwaps = True
For J = 0 To Boundary
If Contact(J) > Contact(J + 1) Then
Temp = Contact(J)
Contact(J) = Contact(J + 1)
Contact(J + 1) = Temp
NoSwaps = False
End If
Next
Boundary = Boundary - 1
Loop Until NoSwaps = True
End Sub


Binary searching
Sub Main()
Dim data() As Integer = {33, 45, 55, 66, 77}
Dim lowerindex, highestindex, middleindex, searchindex,
searchno As Integer
Dim found As Boolean = False
lowerindex = 0
highestindex = data.Length - 1
searchno = Console.ReadLine
While highestindex >= lowerindex And found = False
middleindex = Int((highestindex + lowerindex) / 2)
If data(middleindex) = searchno Then
found = True

TAHA IQBAL

Written for

Course

Document information

Uploaded on
June 6, 2023
Number of pages
19
Written in
2022/2023
Type
SUMMARY

Subjects

CA$15.85
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
tahaiqbal1

Get to know the seller

Seller avatar
tahaiqbal1 FAST
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions