0% found this document useful (0 votes)
6 views

VP PROS 1- 6

The document contains multiple Visual Basic .NET class definitions for a Windows Forms application, each implementing different functionalities such as a basic calculator, Fibonacci sequence generator, summation of integers, and file handling. Each form includes buttons that trigger specific actions, such as displaying results in text boxes or reading/writing files. The code also includes error handling and user interaction elements like message boxes.

Uploaded by

kavistudiokpty
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)
6 views

VP PROS 1- 6

The document contains multiple Visual Basic .NET class definitions for a Windows Forms application, each implementing different functionalities such as a basic calculator, Fibonacci sequence generator, summation of integers, and file handling. Each form includes buttons that trigger specific actions, such as displaying results in text boxes or reading/writing files. The code also includes error handling and user interaction elements like message boxes.

Uploaded by

kavistudiokpty
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/ 43

Public Class Form1

Dim a, b, n As Single
Dim m As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
TextBox1.Text = TextBox1.Text & "1"
End Sub

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


Button2.Click
TextBox1.Text = TextBox1.Text & "2"
End Sub

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


Button3.Click
TextBox1.Text = TextBox1.Text & "3"
End Sub

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


Button4.Click
TextBox1.Text = TextBox1.Text & "4"
End Sub

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


Button5.Click
TextBox1.Text = TextBox1.Text & "5"
End Sub

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


Button6.Click
TextBox1.Text = TextBox1.Text & "6"
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles
Button7.Click
TextBox1.Text = TextBox1.Text & "7"
End Sub

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


Button8.Click
TextBox1.Text = TextBox1.Text & "8"
End Sub

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


Button9.Click
TextBox1.Text = TextBox1.Text & "9"
End Sub

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


Button10.Click
TextBox1.Text = TextBox1.Text & "0"
End Sub

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


Button11.Click
TextBox1.Text = TextBox1.Text & "."
End Sub

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


Button13.Click
a = Val(TextBox1.Text)
TextBox1.Text = ""
m = "+"

End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles
Button14.Click
a = Val(TextBox1.Text)
TextBox1.Text = ""
m = "-"

End Sub

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


Button15.Click
a = Val(TextBox1.Text)
TextBox1.Text = ""
m = "*"

End Sub

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


Button16.Click
a = Val(TextBox1.Text)
TextBox1.Text = ""
m = "/"

End Sub

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


Button12.Click
b = Val(TextBox1.Text)
If m = "+" Then
n = a + b
End If
b = Val(TextBox1.Text)
If m = "-" Then
n = a - b
End If
b = Val(TextBox1.Text)
If m = "*" Then
n = a * b
End If
b = Val(TextBox1.Text)
If m = "/" Then
n = a / b
End If
TextBox1.Text = n
End Sub

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


Button17.Click
TextBox1.Clear()
End Sub
End Class
Public Class Form1

Dim a, b, n, i, s As Integer

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


Button1.Click

n = Val(TextBox1.Text)
a = 0
b = 1
s = 0
TextBox2.Text = a & "" & b & ""

For i = 2 To n – 1

s = a + b
TextBox2.Text = TextBox2.Text & s & ""
a = b
b = s
Next i

If n <= 0 Then
MsgBox("we cannot negative number")

End If

End Sub

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


Button2.Click

TextBox1.Text = ""
TextBox2.Text = ""

End Sub

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


Button3.Click

End

End Sub
End Class
Public Class Form1

Dim i, s, n As Integer

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


Button1.Click

n = Val(TextBox1.Text)

For i = 1 To n

s = 0

s = s + i

TextBox2.Text = Val(TextBox2.Text) + s

Next i

End Sub

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


Button2.Click

TextBox1.Text = ""
TextBox2.Text = ""

End Sub

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


Button3.Click

End

End Sub

End Class
Public Class Form1

Dim i As Integer

Dim j As Integer

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


Button1.Click

Dim pattern As String = ""

For i = 1 To 5

For j = 1 To i

pattern &= "** "

Next j

pattern &= vbCrLf

Next i

MsgBox(pattern)

End Sub

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


Button2.Click

Me.Text = ""

End

End Sub

End Class
OUTPUT FORM :
Public Class Form1

Private Sub NAMEToolStripMenuItem_Click(sender As Object, e As


EventArgs) Handles NAMEToolStripMenuItem.Click

Form2.Show()

End Sub

Private Sub DOBToolStripMenuItem_Click(sender As Object, e As


EventArgs) Handles DOBToolStripMenuItem.Click

Form3.Show()

End Sub

Private Sub AGEToolStripMenuItem_Click(sender As Object, e As


EventArgs) Handles AGEToolStripMenuItem.Click

Form4.Show()

End Sub

End Class
OUTPUT FORM :
FORM :
Public Class Form1

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


Button1.Click

ReadFile(“ YOUR PATH ”) EXAMPLE ("C:\Users\SK\Desktop\PRINCE.txt")

End Sub

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


Button2.Click

TextBox1.Text = ""

End Sub

Private Sub ReadFile(filePath As String)

Try

Dim content As String = System.IO.File.ReadAllText(filePath)

TextBox1.Text = content

Catch ex As Exception

MessageBox.Show("FILE ILLA")

End Try

End Sub

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


Button3.Click

End

End Sub

End Class
OUTPUT FORM :
FORM DESIGN :
Imports System.IO

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

LoadSystemDrives()

End Sub

Private Sub LoadSystemDrives()

For Each drive As DriveInfo In DriveInfo.GetDrives()

ListBox1.Items.Add(drive.Name)

Next

End Sub

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


ListBox1.SelectedIndexChanged

Try

DisplayDirectoryContents()

Catch ex As Exception

ShowErrorMessage(ex.Message)

End Try

End Sub

Private Sub DisplayDirectoryContents()

ListBox2.Items.Clear()

Dim selectedDirectory As String = ListBox1.SelectedItem.ToString()

For Each item As String In Directory.GetFileSystemEntries(selectedDirectory)

ListBox2.Items.Add(Path.GetFileName(item))
Next

End Sub

Private Sub button1_Click(sender As Object, e As EventArgs) Handles button1.Click

Dim selectedDirectory As String = ListBox1.ToString()

Dim saveDialog As New SaveFileDialog() With {.Filter = "Text Files (*.txt)|*.txt|All


Files (*.*)|*.*"}
If saveDialog.ShowDialog() = DialogResult.OK Then

Dim filePath As String = Path.Combine(selectedDirectory, saveDialog.FileName)

If File.Exists(filePath) Then

ShowErrorMessage("File already exists in the selected directory.")

Else

File.WriteAllText(filePath, TextBox1.Text)

ShowSuccessMessage("File save aarichi!")

End If

End If

End Sub

Private Sub ShowErrorMessage(message As String)

MessageBox.Show(message, "Error", MessageBoxButtons.OK,


MessageBoxIcon.Error)

End Sub

Private Sub ShowInfoMessage(message As String)

MessageBox.Show(message, "Information", MessageBoxButtons.OK,


MessageBoxIcon.Information)

End Sub

Private Sub ShowSuccessMessage(message As String)

MessageBox.Show(message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

End

End Sub

End Class
OUTPUT :
Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim openFileDialog1 As New OpenFileDialog()

If openFileDialog1.ShowDialog() = DialogResult.OK Then

TextBox1.Text = System.IO.File.ReadAllText(openFileDialog1.FileName)

End If

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

Dim saveFileDialog1 As New SaveFileDialog()

If saveFileDialog1.ShowDialog() = DialogResult.OK Then

System.IO.File.WriteAllText(saveFileDialog1.FileName,TextBox1.Text)

MessageBox.Show("File save panniyachi.")

End If

End Sub

Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

TextBox1.Text = ""

End Sub

Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click

End

End Sub

End Class
FORM DESIGN :
OUTPUT :

You might also like