Visual Basic
Visual Basic
principal = Convert.ToDouble(Console.ReadLine())
Console.WriteLine("Enter Annual Interest Rate (in %):")
rate = Convert.ToDouble(Console.ReadLine())
Console.WriteLine("Enter Time (in years):")
time = Convert.ToDouble(Console.ReadLine())
For i As Integer = 0 To 2
For j As Integer = 0 To 2
If my2DArray(i, j) = searchValue Then
Console.WriteLine($"Value {searchValue} found at
position ({i}, {j}).")
found = True
Exit For ' Exit the inner loop
End If
Next
If found Then Exit For ' Exit the outer loop
Next
If Not found Then
Console.WriteLine($"Value {searchValue} not found in the
2D array.")
End If
Console.ReadLine() ' Wait for user input to keep the console
open
End Sub
End Module
Output
-
5- Switch case in VB Input
Module Module
Sub Main()
' Declare a variable
Dim dayNumber As Integer
Output
-
6-Fibonacci series up to 5 Numbers Input
Module Module1
Sub Main()
' Variables to store the first two numbers of the Fibonacci
series
Dim num1 As Integer = 0
Dim num2 As Integer = 1
Output
9-Swap of two numbers using function Input
Module Module1
Sub Main()
Dim num1 As Integer, num2 As Integer
Input
Output
10-Find the length of a string.
Input
Module Module1
Sub Main()
Console.Write("Enter a string: ")
Dim input As String = Console.ReadLine()
Input
Output
Console.ReadLine()
End Sub
Input
Output
12-Create multiple forms in VB. Input
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
Handles Button1.Click
Dim form2 As New Form2()
form2.Show()
Me.Hide()
End Sub
End Class
13-Reverse of a number.
Input
Module Module1
Sub Main()
Console.Write("Enter a number: ")
Dim num As Integer = Convert.ToInt32(Console.ReadLine())
Dim reversed As Integer = ReverseNumber(num)
Output
Output
15-To print
1
12 123 1234 12345
Input
Module Module1
Sub Main()
For i As Integer = 1 To 5
For j As Integer = 1 To i
Console.Write(j)
Next
Console.WriteLine()
Next
Console.ReadLine()
End Sub
End Module
Output