Lab2
2.Write Console application to generate Fibonacci Sequence
Module Fibonacci
Sub Main()
Dim n, f1, f2, f3 As Integer
Console.Write("Enter Your Term:")
n = CInt(Console.ReadLine())
f1 = 0
f2 = 1
f3 = 0
While n <> 0
Console.Write(f3 & " ")
f1 = f2
f2 = f3
f3 = f1 + f2
n = n - 1
End While
End Sub
End Module
3.Write a program in VB.Net Console application
to perform String Operations.
Module Module1
Sub Main()
Dim s3 As String
s3 = s1 & s2
Console.WriteLine("after cancat" & s3)
s3 = LCase(s1)
Console.WriteLine("LowerCase:" & s3)
s3 = s1.ToUpper()
Console.WriteLine("uppercase " & s3)
s3 = s1.Substring(0, 7)
Console.WriteLine("sub string" & s3)
s3 = s1.Replace("vb.net", "java")
Console.WriteLine("after replace" & s3)
s3 = s1.Remove(0, 11)
Console.WriteLine("after removing" & s3)
Console.WriteLine("length of str1 string" & s1.Length())
Console.WriteLine("length of str2 string" & s2.Length())
Console.ReadLine()
End Sub
End Module
4.Convert Text into Bold, Italic and
underline using check box
public class Form1
Private Sub Checkbox1_Checkedchanged( Byval sender As System.Object,
Byval e As System.EventArgs) Handles Checkbox1.CheckedChanged
Textbox1.Font = New Font(TextBox1.Font, Textbox1.Font.Style
Xor FontStyle.Bold)
End Sub
Private Sub Checkbox2_Checkedchanged( Byval sender As System.Object, Byval e As System.EventArgs) Handles Checkbox2.CheckedChanged
Textbox1.Font = New Font(TextBox1.Font, Textbox1.Font.Style Xor FontStyle.Italic)
End Sub
Private Sub Checkbox3_Checkedchanged( Byval sender As System.Object, Byval e As System.EventArgs) Handles Checkbox3.CheckedChanged
Textbox1.Font = New Font(TextBox1.Font, Textbox1.Font.Style Xor FontStyle.Underline)
End Sub
End Class
public class Form1
Byval e As System.EventArgs) Handles Checkbox1.CheckedChanged
Xor FontStyle.Bold)
End Sub
Private Sub Checkbox2_Checkedchanged( Byval sender As System.Object, Byval e As System.EventArgs) Handles Checkbox2.CheckedChanged
End Sub
Private Sub Checkbox3_Checkedchanged( Byval sender As System.Object, Byval e As System.EventArgs) Handles Checkbox3.CheckedChanged
End Class
Lab 1
1.Write a Vb.net console application to find
factorial of a given number
Module Factorial
Sub main()
Dim n, i, f As Integer
Console.Write("Enter a Number: ")
n = CInt(Console.ReadLine())
f = 1
For i = 1 To n
f = f * i
Next
Console.WriteLine("Factorial of " + n.ToString() + " is " + f.ToString())
End Sub
End Module
Module ArmstrongNumber
Sub Main()
Dim n, r, sum, m As Integer
Console.Write("Enter a number= ")
n = CInt(Console.ReadLine())
sum = 0
m = n
While n <> 0
r = n Mod 10
sum =sum + Math.Pow(r, 3)
n = n \ 10
End While
If sum = m Then
Console.WriteLine(t.ToString + " is a Armstrong Number")
Else
Console.WriteLine(t.ToString + " is NOT an Armstrong Number")
End If
End Sub
End Module
3.Write vb.net
console application to implement Exception Handling
Module Module1
Sub Main()
Dim a, b, c As Integer
Console.WriteLine("enter
two number")
Try
a = CInt(Console.ReadLine())
b = CInt(Console.ReadLine())
c = a / b
Console.WriteLine("quotient
" & c)
Catch e As ArithmeticException
Console.WriteLine("cannot
divide by zero")
Finally
Console.WriteLine("this
is always excuted")
End Try
End Sub
End Module
4. Write a vb.net windows application to Zoom In/Zoom Out an image
Image-
localsource>import
Sizemode>striceimage
Button1-text>zoom in
Button2-text>zomm out
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
PictureBox1.Width = PictureBox1.Width + 20
PictureBox1.Height = PictureBox1.Height + 20
End Sub
PrivateSub Button2_Click(sender AsObject, e AsEventArgs) Handles Button2.Click
PictureBox1.Width =
PictureBox1.Width - 20
PictureBox1.Height =
PictureBox1.Height - 20
End Sub
End Class
No comments:
Post a Comment