SlideShare a Scribd company logo
A Program in Linear Search Using Visual Basic 2008 (version 9.0)
                          By Ariel T. Sumagaysay, MSCS

A. Form Design

Design the form shown below using the Visual Basic 2008:




B. Components

      The following are the components of the program: 1 Form, 1 GroupBox, 4 Labels,
      1 ListBox, 5 TextBoxes and 5 Buttons.
2


C. Code Listings

'LINEAR SEARCH
'PROGRAM BY ARIEL T. SUMAGAYSAY
'COLLEGE OF INFORMATION & COMMUNICATION TECHNOLOGY
'WEST NEGROS UNIVERSITY
'DECEMBER 15, 2008

Public Class Form1

    'Variables
    Dim nNumberOfElements As Integer
    Dim sNumbers As String
    Dim nFind As Integer
    Dim n As Integer
    Dim x As Integer
    Dim s As String

    'One Dimensional Array
    Dim aInputSet() As Integer

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
        'Setting Buttons - controls
        Button2.Enabled = False
        Button3.Enabled = False
        Button4.Enabled = False

        TextBox1.Enabled = True
        TextBox6.Enabled = False
        TextBox7.Enabled = False

        TextBox1.Text = " "
        TextBox2.Text = " "
        TextBox3.Text = " "
        TextBox6.Text = " "
        TextBox7.Text = " "
        ListBox1.Items.Clear()

        'Initialize variables
        nNumberOfElements = 0
        n = 0
        x = 0
        s = " "
        sNumbers = " "        'Set string of numbers to NULL
        nFind = 0

        'Set the Number of Elements
        ReDim aInputSet(0)
    End Sub
3

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
        'Re - setting Buttons
        Button2.Enabled = False
        Button3.Enabled = False
        Button4.Enabled = False
        Button5.Enabled = True

        TextBox1.Enabled = True
        TextBox6.Enabled = False
        TextBox7.Enabled = False

        TextBox1.Text = " "
        TextBox2.Text = " "
        TextBox3.Text = " "
        TextBox6.Text = " "
        TextBox7.Text = " "
        ListBox1.Items.Clear()

        'Initialize variables
        nNumberOfElements = 0
        n = 0
        x = 0
        s = " "
        sNumbers = " "        'Set string of numbers to NULL
        nFind = 0

        'Set the Number of Elements
        ReDim aInputSet(0)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
        'Terminate Program
        End

    End Sub
    Private Sub bubblesort()
        'Sort the elements using bubblesort
        Static a As Integer
        Static b As Integer
        Static temp As Integer
        Static sHereNumbers As String

        'initialize variables
        a = 0
        b = 0
        temp = 0
        sHereNumbers = " "

        For a = 1 To n
            For b = 1 To n - 1
4

                      If (aInputSet(b) > aInputSet(b + 1)) Then
                          temp = aInputSet(b)
                          aInputSet(b) = aInputSet(b + 1)
                          aInputSet(b + 1) = temp
                      End If
               Next
        Next

        'display list
        For a = 1 To n
             sHereNumbers = sHereNumbers + Str(aInputSet(a)) & " "
             TextBox3.Text = sHereNumbers
        Next

        'Enable Search button
        Button3.Enabled = True
        TextBox7.Enabled = True
    End Sub

    Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
        'Setting Buttons
        Button4.Enabled = True
        Button5.Enabled = False

       TextBox6.Enabled = True
       TextBox1.Enabled = False

       'Get number of elements
       nNumberOfElements = CInt(TextBox1.Text)
       n = nNumberOfElements

        ReDim aInputSet(n)

        'set command button label
        s = Format(1, "0#")
        Button4.Text = "&ENTER ELEMENT " + s
    End Sub

    Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
        Static y As Integer
        y = 0

        'Enter numbers
        If TextBox6.Text <> " " Then
            x = x + 1
            y = x

               s = Format(y + 1, "0#")
               Button4.Text = "&ENTER ELEMENT " + s
               aInputSet(x) = CInt(TextBox6.Text)

               If x = n Then
                   Button4.Enabled = False
                   TextBox6.Enabled = False
                   Button4.Text = "&ENTER ELEMENT"
5


                  Call bubblesort()
              End If

            sNumbers = sNumbers & TextBox6.Text & " "
            TextBox2.Text = sNumbers
            TextBox6.Text = " "
        End If


    End Sub

    Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
        Static z As Integer
        Static bFind As Boolean

        'Setting Buttons & Initialization
        Button2.Enabled = True
        bFind = False
        ListBox1.Items.Clear()

        'Searching
        nFind = CInt(TextBox7.Text)

        For z = 1 To n
             If nFind = aInputSet(z) Then
                 ListBox1.Items.Add("Number is found on location " & Str(z))
                 bFind = True
             End If
        Next

        If bFind = False Then
            ListBox1.Items.Add(" Number is NOT FOUND on the LIST! ")
        End If

    End Sub
End Class

More Related Content

What's hot

Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
lupe ga
 
Lampiran source code
Lampiran source codeLampiran source code
Lampiran source codeancunk
 
How to Write Better Code with Mutation Testing
How to Write Better Code with Mutation TestingHow to Write Better Code with Mutation Testing
How to Write Better Code with Mutation Testing
John Backus
 
Andres y keitleen
Andres y keitleenAndres y keitleen
Andres y keitleen
keitleen guzman
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5sotlsoc
 
Understanding Lemon Generated Parser
Understanding Lemon Generated ParserUnderstanding Lemon Generated Parser
Understanding Lemon Generated Parser
vivekanandan r
 
Python-Tuples
Python-TuplesPython-Tuples
Python-Tuples
Krishna Nanda
 
Understanding Lemon Generated Parser Final
Understanding Lemon Generated Parser FinalUnderstanding Lemon Generated Parser Final
Understanding Lemon Generated Parser Final
vivekanandan r
 
Introduction to Python and TensorFlow
Introduction to Python and TensorFlowIntroduction to Python and TensorFlow
Introduction to Python and TensorFlow
Bayu Aldi Yansyah
 
Python002
Python002Python002
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventasDAYANA RETO
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
Darwin Durand
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraDeependra Ariyadewa
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
Giovanni Della Lunga
 
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third Year
Dezyneecole
 
Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0
Sencha
 
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD  MAKING IN PAYTHON BY ROHIT MALAVNOTEPAD  MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
Rohit malav
 
Introduction to python programming 2
Introduction to python programming   2Introduction to python programming   2
Introduction to python programming 2
Giovanni Della Lunga
 

What's hot (20)

Ejemplo radio
Ejemplo radioEjemplo radio
Ejemplo radio
 
Lampiran source code
Lampiran source codeLampiran source code
Lampiran source code
 
How to Write Better Code with Mutation Testing
How to Write Better Code with Mutation TestingHow to Write Better Code with Mutation Testing
How to Write Better Code with Mutation Testing
 
Andres y keitleen
Andres y keitleenAndres y keitleen
Andres y keitleen
 
Chapter 11.5
Chapter 11.5Chapter 11.5
Chapter 11.5
 
Understanding Lemon Generated Parser
Understanding Lemon Generated ParserUnderstanding Lemon Generated Parser
Understanding Lemon Generated Parser
 
Python-Tuples
Python-TuplesPython-Tuples
Python-Tuples
 
Understanding Lemon Generated Parser Final
Understanding Lemon Generated Parser FinalUnderstanding Lemon Generated Parser Final
Understanding Lemon Generated Parser Final
 
3
33
3
 
Introduction to Python and TensorFlow
Introduction to Python and TensorFlowIntroduction to Python and TensorFlow
Introduction to Python and TensorFlow
 
Python002
Python002Python002
Python002
 
Sistema de ventas
Sistema de ventasSistema de ventas
Sistema de ventas
 
SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)SISTEMA DE FACTURACION (Ejemplo desarrollado)
SISTEMA DE FACTURACION (Ejemplo desarrollado)
 
Store and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and CassandraStore and Process Big Data with Hadoop and Cassandra
Store and Process Big Data with Hadoop and Cassandra
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
 
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third Year
 
Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0Migrating from Ext GWT 2.x to 3.0
Migrating from Ext GWT 2.x to 3.0
 
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD  MAKING IN PAYTHON BY ROHIT MALAVNOTEPAD  MAKING IN PAYTHON BY ROHIT MALAV
NOTEPAD MAKING IN PAYTHON BY ROHIT MALAV
 
Listing program
Listing programListing program
Listing program
 
Introduction to python programming 2
Introduction to python programming   2Introduction to python programming   2
Introduction to python programming 2
 

Similar to Linear Search Program in Visual Basic 2008

Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2Jomel Penalba
 
Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
Marwane Lamouri
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabarPractica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
Yosselin Marquez
 
Ejercicio sql server vs visual .net
Ejercicio sql server vs visual .netEjercicio sql server vs visual .net
Ejercicio sql server vs visual .net
Ayuda Universidad
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx
corbing9ttj
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx
corbing9ttj
 
Tic tac toe code
Tic tac toe codeTic tac toe code
Tic tac toe code
Adolfo Jimenez
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
dickonsondorris
 
Reservasi hotel
Reservasi hotelReservasi hotel
Reservasi hoteldian pw
 
Cómo programar label
Cómo programar labelCómo programar label
Cómo programar label
danna gabriela
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
Dr.M.Karthika parthasarathy
 
1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf
aniljain719651
 
1. Section1.- Populating the list of persons on the person listing.pdf
1. Section1.- Populating the list of persons on the person listing.pdf1. Section1.- Populating the list of persons on the person listing.pdf
1. Section1.- Populating the list of persons on the person listing.pdf
aniljain719651
 
Laboratory activity 3 b3
Laboratory activity 3 b3Laboratory activity 3 b3
Laboratory activity 3 b3Jomel Penalba
 
File handling in pythan.pptx
File handling in pythan.pptxFile handling in pythan.pptx
File handling in pythan.pptx
NawalKishore38
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
rajeshjangid1865
 

Similar to Linear Search Program in Visual Basic 2008 (20)

Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2
 
Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
 
Practica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabarPractica porfe agustin eliminar y grabar
Practica porfe agustin eliminar y grabar
 
Ejercicio sql server vs visual .net
Ejercicio sql server vs visual .netEjercicio sql server vs visual .net
Ejercicio sql server vs visual .net
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx
 
Tic tac toe code
Tic tac toe codeTic tac toe code
Tic tac toe code
 
Calculadora
CalculadoraCalculadora
Calculadora
 
Use the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docxUse the following data set that compares age to average years lef.docx
Use the following data set that compares age to average years lef.docx
 
Reservasi hotel
Reservasi hotelReservasi hotel
Reservasi hotel
 
Cómo programar label
Cómo programar labelCómo programar label
Cómo programar label
 
.net progrmming part4
.net progrmming part4.net progrmming part4
.net progrmming part4
 
1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf1. Section1.- Populating the list of persons on the person listing f.pdf
1. Section1.- Populating the list of persons on the person listing f.pdf
 
1. Section1.- Populating the list of persons on the person listing.pdf
1. Section1.- Populating the list of persons on the person listing.pdf1. Section1.- Populating the list of persons on the person listing.pdf
1. Section1.- Populating the list of persons on the person listing.pdf
 
Laboratory activity 3 b3
Laboratory activity 3 b3Laboratory activity 3 b3
Laboratory activity 3 b3
 
File handling in pythan.pptx
File handling in pythan.pptxFile handling in pythan.pptx
File handling in pythan.pptx
 
Colegio municipal
Colegio municipalColegio municipal
Colegio municipal
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
Docimp
DocimpDocimp
Docimp
 
Coding java.txt
Coding java.txtCoding java.txt
Coding java.txt
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 

Linear Search Program in Visual Basic 2008

  • 1. A Program in Linear Search Using Visual Basic 2008 (version 9.0) By Ariel T. Sumagaysay, MSCS A. Form Design Design the form shown below using the Visual Basic 2008: B. Components The following are the components of the program: 1 Form, 1 GroupBox, 4 Labels, 1 ListBox, 5 TextBoxes and 5 Buttons.
  • 2. 2 C. Code Listings 'LINEAR SEARCH 'PROGRAM BY ARIEL T. SUMAGAYSAY 'COLLEGE OF INFORMATION & COMMUNICATION TECHNOLOGY 'WEST NEGROS UNIVERSITY 'DECEMBER 15, 2008 Public Class Form1 'Variables Dim nNumberOfElements As Integer Dim sNumbers As String Dim nFind As Integer Dim n As Integer Dim x As Integer Dim s As String 'One Dimensional Array Dim aInputSet() As Integer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Setting Buttons - controls Button2.Enabled = False Button3.Enabled = False Button4.Enabled = False TextBox1.Enabled = True TextBox6.Enabled = False TextBox7.Enabled = False TextBox1.Text = " " TextBox2.Text = " " TextBox3.Text = " " TextBox6.Text = " " TextBox7.Text = " " ListBox1.Items.Clear() 'Initialize variables nNumberOfElements = 0 n = 0 x = 0 s = " " sNumbers = " " 'Set string of numbers to NULL nFind = 0 'Set the Number of Elements ReDim aInputSet(0) End Sub
  • 3. 3 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click 'Re - setting Buttons Button2.Enabled = False Button3.Enabled = False Button4.Enabled = False Button5.Enabled = True TextBox1.Enabled = True TextBox6.Enabled = False TextBox7.Enabled = False TextBox1.Text = " " TextBox2.Text = " " TextBox3.Text = " " TextBox6.Text = " " TextBox7.Text = " " ListBox1.Items.Clear() 'Initialize variables nNumberOfElements = 0 n = 0 x = 0 s = " " sNumbers = " " 'Set string of numbers to NULL nFind = 0 'Set the Number of Elements ReDim aInputSet(0) End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'Terminate Program End End Sub Private Sub bubblesort() 'Sort the elements using bubblesort Static a As Integer Static b As Integer Static temp As Integer Static sHereNumbers As String 'initialize variables a = 0 b = 0 temp = 0 sHereNumbers = " " For a = 1 To n For b = 1 To n - 1
  • 4. 4 If (aInputSet(b) > aInputSet(b + 1)) Then temp = aInputSet(b) aInputSet(b) = aInputSet(b + 1) aInputSet(b + 1) = temp End If Next Next 'display list For a = 1 To n sHereNumbers = sHereNumbers + Str(aInputSet(a)) & " " TextBox3.Text = sHereNumbers Next 'Enable Search button Button3.Enabled = True TextBox7.Enabled = True End Sub Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click 'Setting Buttons Button4.Enabled = True Button5.Enabled = False TextBox6.Enabled = True TextBox1.Enabled = False 'Get number of elements nNumberOfElements = CInt(TextBox1.Text) n = nNumberOfElements ReDim aInputSet(n) 'set command button label s = Format(1, "0#") Button4.Text = "&ENTER ELEMENT " + s End Sub Private Sub Button4_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Static y As Integer y = 0 'Enter numbers If TextBox6.Text <> " " Then x = x + 1 y = x s = Format(y + 1, "0#") Button4.Text = "&ENTER ELEMENT " + s aInputSet(x) = CInt(TextBox6.Text) If x = n Then Button4.Enabled = False TextBox6.Enabled = False Button4.Text = "&ENTER ELEMENT"
  • 5. 5 Call bubblesort() End If sNumbers = sNumbers & TextBox6.Text & " " TextBox2.Text = sNumbers TextBox6.Text = " " End If End Sub Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Static z As Integer Static bFind As Boolean 'Setting Buttons & Initialization Button2.Enabled = True bFind = False ListBox1.Items.Clear() 'Searching nFind = CInt(TextBox7.Text) For z = 1 To n If nFind = aInputSet(z) Then ListBox1.Items.Add("Number is found on location " & Str(z)) bFind = True End If Next If bFind = False Then ListBox1.Items.Add(" Number is NOT FOUND on the LIST! ") End If End Sub End Class