stu nicholls dot com | menu - Professional dropdown #3



Programs

Program to implement stack:
Public Class Form1
Dim stack(5) As Integer
Dim Stack_top As Integer = 4
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Stack_top > 0 Then
Stack_top -= 1
stack(Stack_top) = TextBox1.Text
MsgBox("Successful Push")
Else
MsgBox("Stack is Full: Can't Push")
End If
TextBox1.Clear()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Stack_top <= 3 Then
TextBox2.Text = stack(Stack_top)
Stack_top += 1
Else
TextBox2.Text = "Stack is Empty"
End If
End Sub
End Class

Ouput:

Program to implement Inheritence:
Public Class Form1
Dim Student_IT As MScIT
Dim Student_MBA As MBA
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Student_IT = New MScIT(Me)
Student_IT.Disp_RegNo(101)
Student_IT.Disp_Name("Mr. Chamrong")
Student_IT.Disp_Subjects()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Student_MBA = New MBA(Me)
Student_MBA.Disp_RegNo(201)
Student_MBA.Disp_Name("Mr. Samnag")
Student_MBA.Disp_Subjects()
End Sub
End Class
Public Class base1
Protected mainform As Form1
Public Sub New(ByRef form As Form1)
mainform = form
End Sub
Public Sub Disp_RegNo(ByVal RN As Integer)
mainform.TextBox1.Text = RN
End Sub
Public Sub Disp_Name(ByVal Nm As String)
mainform.TextBox2.Text = Nm
End Sub
End Class
Public Class MscIT Inherits base1
Public Sub New(ByRef form As Form1)
MyBase.New(form)
End Sub
Public Sub Disp_Subjects()
mainform.TextBox3.Text = "Msc-IT
Subjects:VB.Net,COA,AI"
End Sub
End Class
Public Class MBA Inherits base1
Public Sub New(ByRef form As Form1)
MyBase.New(form)
End Sub
Public Sub Disp_Subjects()
mainform.TextBox3.Text = "MBA Subjects: Marketing, Advertising, Finance"
End Sub
End Class

Function for Linear Search:
Public Function LinearSearch(ByVal a As Array, ByVal m As Integer, ByVal SKey As Integer) As Integer
Dim i, flg As Integer
For i = 0 To m
If (a(i) = SKey) Then
flg = 1
Return 1
End If
Next i
If (flg = 0) Then
Return 0
End If
End Function

Polymorphism<< Previous

comments powered by Disqus
click here
Footer1