VB.net
VB.net
PROGRAMM NAME:-BCA
COURSE NAME: VB.NET
End Sub
End Sub
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles
Button3.Click
a = TextBox1.Text
b = TextBox2.Text
c=a*b
TextBox3.Text = c
End Sub
End Sub
End Class
2.Write a program in Visual basic to find whether a given character is vowel or not.Display the
result in a message box.
Imports System.Net.Configuration
Dim ch As Char
ch = TextBox1.Text
Select Case ch
End Select
End Sub
End Class
3.Create GUI From Show Below and check the eligibility for Voting.
age = Val(t1.Text)
End If
End Sub
t1.Text = ""
End Sub
Button3.Click
Close()
End Sub
End Class
4.Show that How many times a page has been clicked.
Imports System.Net.Security
btnCount.Click
clickcount += 1
clickcount = 1
End If
Label1.Text = clickcount.ToString("00")
End Sub
End Class
6. Create GUI Form Show Below.
Public Class Form1
Button1.Click
If Val(TextBox1.Text) > Val(TextBox2.Text) Then
TextBox3.Text = "First number is Biggest"
Else
TextBox3.Text = " Second number is Biggest"
End If
End Sub
TextBox1.TextChanged
End Sub
End Class
8.Design and code to print a table of a given no in textbox.
Public Class Form1
Dim mu As Integer = 1
mu += 1 'mu= mu+1'
ListBox1.Refresh()
End While
End Sub
ListBox1.Items.Clear()
ListBox1.Refresh()
TextBox1.Text = ""
End Sub
Me.Close()
End Sub
End Class
10.Design and code a Calculator by using Control Array.
Public Class Form1
Dim value1, value2 As Integer
Dim sign As String
End Sub
Else
TextBox1.Text = value1 / value2
End If
End Sub
End Sub
End Class
12. Design and code to generate fibonacii series on a label upto entered limit.
End Sub
End Class
5.Demomstrate the use of Option with strict ,compare & explicit.
I. Option Strict.
Module Program
Sub Main()
' This will give a compile-time error because Option Strict is on
' Dim x As Integer = "123" ' Implicit conversion from String to Integer
Module Program
Sub Main()
Dim str1 As String = "apple"
Dim str2 As String = "Apple"
Module Program
Sub Main()
' This will give a compile-time error because the variable is not declared
' x = 10
for i=0 to 1
for j=0 to 1
sum(i,j)=br(i,j)+ar(i,j)
subtract(I,j)=ar(I,j)-br(i,j)
Next j
Next i
for i=0 to 1
for j=0 to 1
console.WriteLine(sum(i,j))
Next j
Next i
for i=0 to 1
for j=0 to 1
console.WriteLine(subtract(i,j))
Next j
Next i
console.ReadLine()
End Sub
End Module
Output:
the sum of two array is
3
13
3
9.Design and code to check whether the entered no is Armstrong and palindrome or
not.
Module Program
temp \= 10
End While
End Function
num \= 10
End While
End Function
If isArmstrong Then
Else
End If
If isPalindrome Then
Else
End If
Console.ReadKey()
End Sub
End Module
Output:
ListBox1.Items.Add(value.Trim())
Next
txtInput.Clear()
End Sub
ListBox1.Items.Remove(selectedItem)
preservedValues.Remove(selectedItem)
End If
End Sub
' Checkbox changed event to preserve ListBox contents
If chkPreserve.Checked Then
ListBox1.Items.Clear()
ListBox1.Items.Add(value)
Next
Else
ListBox1.Items.Clear()
End If
End Sub
' Optional: Saving data to a file when closing the application (to preserve across sessions)
If chkPreserve.Checked Then
System.IO.File.WriteAllLines("preservedData.txt", preservedValues)
End If
End Sub
If System.IO.File.Exists("preservedData.txt") Then
preservedValues = System.IO.File.ReadAllLines("preservedData.txt").ToList()
ListBox1.Items.Add(value)
Next
End If
End Sub
End Class
Output:
13. Design and code for insertion sorting by using a user define sub-routine.
Imports system
Module Module1
Sub Main()
' Example array to be sorted
Dim numbers As Integer() = {29, 10, 14, 37, 13}
' Loop through the array starting from the second element
For i = 1 To n - 1
key = arr(i)
j=i-1
' Move elements of arr(0..i-1), that are greater than key, to one position ahead
While j >= 0 AndAlso arr(j) > key
arr(j + 1) = arr(j)
j -= 1
End While
Sorted Array:
10 13 14 29 37
14.Design and code for Selection sorting by using a user-define sub-routine.
Imports System
Module Program
Sub Main()
' Initialize an array with unsorted values
Dim numbers As Integer() = {64, 25, 12, 22, 11}
For j As Integer = i + 1 To n - 1
If arr(j) < arr(minIndex) Then
minIndex = j
End If
Next
Output:
15.Design and code for Bubble sorting by using a user-define sub-routine.
Imports System
Module Program
Sub Main()
Console.WriteLine("Original Array:")
DisplayArray(numbers)
BubbleSort(numbers)
Console.WriteLine("Sorted Array:")
DisplayArray(numbers)
Console.ReadLine()
End Sub
For i As Integer = 0 To n - 2
swapped = False
For j As Integer = 0 To n - i - 2
' Compare adjacent elements
' Swap if the element found is greater than the next element
arr(j) = arr(j + 1)
arr(j + 1) = temp
swapped = True
End If
Next
' If no two elements were swapped in the inner loop, then the array is sorted
Exit For
End If
Next
End Sub
Next
Console.WriteLine()
End Sub
End Module
Output: