0% found this document useful (0 votes)
18 views7 pages

Ilovepdf Merged

Uploaded by

tekenme69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views7 pages

Ilovepdf Merged

Uploaded by

tekenme69
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

3. Develop a GUI in VB.

NET with Rich Text Box and ComboBox for formatting text
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles
ComboBox1.SelectedIndexChanged
Dim selectedFormat As String = ComboBox1.SelectedItem.ToString()

Select Case selectedFormat


Case "Bold"
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Bold)
Case "Italic"
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Italic)
Case "Underline"
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont,
FontStyle.Underline)
' Add more cases for other formatting options as needed
End Select
End Sub
5. Create a VB.NET form to pick a date and display day, month, and year.

Private Sub DateTimePicker1_ValueChanged(sender As Object, e As EventArgs) Handles


DateTimePicker1.ValueChanged
Dim selectedDate As Date = DateTimePicker1.Value

Label1.Text = "Day: " & selectedDate.Day.ToString()


Label2.Text = "Month: " & selectedDate.Month.ToString()
Label3.Text = "Year: " & selectedDate.Year.ToString()
End Sub
2. Write a program in C# to find the factorial, Fibonacci series, or Prime numbers.
using System;

class Program
{
static void Main(string[] args)
{
int choice;

do
{
Console.WriteLine("Menu:");
Console.WriteLine("1. Calculate Factorial");
Console.WriteLine("2. Generate Fibonacci Series");
Console.WriteLine("3. Check for Prime Number");
Console.WriteLine("4. Exit");
Console.Write("Enter your choice: ");

choice = Convert.ToInt32(Console.ReadLine());

switch (choice)
{
case 1:
CalculateFactorial();
break;
case 2:
GenerateFibonacciSeries();
break;
case 3:
CheckPrimeNumber();
break;
case 4:
Console.WriteLine("Exiting...");
break;
default:
Console.WriteLine("Invalid choice. Please try again.");
break;
}
} while (choice != 4);
}

static void CalculateFactorial()


{
int num, factorial = 1;

Console.Write("Enter a number to calculate factorial: ");


num = Convert.ToInt32(Console.ReadLine());
for (int i = 1; i <= num; i++)
{
factorial *= i;
}

Console.WriteLine("Factorial of {0} is {1}", num, factorial);


}

static void GenerateFibonacciSeries()


{
int n, t1 = 0, t2 = 1, nextTerm;

Console.Write("Enter the number of terms for Fibonacci Series: ");


n = Convert.ToInt32(Console.ReadLine());

Console.Write("Fibonacci Series: ");

for (int i = 1; i <= n; ++i)


{
Console.Write(t1 + " ");
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;
}

Console.WriteLine();
}

static void CheckPrimeNumber()


{
int num, i, flag = 0;

Console.Write("Enter a positive integer to check for prime: ");


num = Convert.ToInt32(Console.ReadLine());

if (num == 0 || num == 1)
{
Console.WriteLine("{0} is not a prime number.", num);
return;
}

for (i = 2; i <= num / 2; ++i)


{
if (num % i == 0)
{
flag = 1;
break;
}
}

if (flag == 0)
{
Console.WriteLine("{0} is a prime number.", num);
}
else
{
Console.WriteLine("{0} is not a prime number.", num);
}
}
}
4. Write a program to calculate the area of a circle (VB.NET and C#).
*VB.NET
Module Module1

Sub Main()
Dim radius As Double = InputBox("Enter the radius of the circle:")

Dim area As Double = Math.PI * radius * radius

Console.WriteLine("The area of the circle is: {0}", area)


Console.ReadLine()
End Sub

End Module
*C#
using System;

class Program
{
static void Main(string[] args)
{
Console.Write("Enter the radius of the circle: ");
double radius = Convert.ToDouble(Console.ReadLine());

double area = Math.PI * radius * radius;

Console.WriteLine("The area of the circle is: {0}", area);


}
}
1. Write a VB.NET program to check whether a string is a palindrome.

Module Module1

Sub Main()
Dim strInput As String = InputBox("Enter a string to check for palindrome:")

If IsPalindrome(strInput) Then
Console.WriteLine("{0} is a palindrome.", strInput)
Else
Console.WriteLine("{0} is not a palindrome.", strInput)
End If

Console.ReadLine()
End Sub

Function IsPalindrome(str As String) As Boolean


Dim reversedStr As String = ""

For i As Integer = str.Length - 1 To 0 Step -1


reversedStr &= str(i)
Next

Return str.ToLower() = reversedStr.ToLower()


End Function

End Module

You might also like