Sei sulla pagina 1di 6

ACTIVITY 1-DIALOG BOX

DIALOGBOX.VB
Imports System.IO
Public Class Form1
Inherits System.Windows.Forms.Form
Private FileName As String
Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles OpenToolStripMenuItem.Click
Dim openfiledialog1 As New OpenFileDialog
Dim sr As StreamReader
Try
With openfiledialog1
.Filter = "File Text (*.txt)|*.txt|" & "All File|*.*"
If .ShowDialog() = DialogResult.OK Then
FileName = .FileName
sr = New StreamReader(.OpenFile)
Me.Text = sr.ReadToEnd()
End If
End With
Catch es As Exception
MessageBox.Show(es.Message)
Finally
If Not (sr Is Nothing) Then
sr.Close()
End If
End Try
End Sub
Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles SaveToolStripMenuItem.Click
Dim SaveFileDialog1 As New SaveFileDialog
Dim streamw As StreamWriter
Try
With SaveFileDialog1
.FileName = FileName
.Filter = "Text files (*.txt)|*.txt|" & "All files|*.*"
If .ShowDialog() = DialogResult.OK Then
FileName = .FileName
streamw = New StreamWriter(FileName)
streamw.Write(TextBox1.Text)
End If
End With
Catch es As Exception
MessageBox.Show(es.Message)
Finally
If Not (streamw Is Nothing) Then
streamw.Close()
End If
End Try
End Sub
Private Sub SelectFontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles SelectFontToolStripMenuItem.Click
Dim dlgFontDialog As FontDialog = New FontDialog

Dim result As DialogResult


result = dlgFontDialog.ShowDialog
TextBox1.Font = dlgFontDialog.Font
End Sub
Private Sub SelectForeColorToolStripMenuItem_Click(sender As System.Object, e As
System.EventArgs) Handles SelectForeColorToolStripMenuItem.Click
Dim dlgColorDialog As ColorDialog = New ColorDialog
Dim result As DialogResult
result = dlgColorDialog.ShowDialog
TextBox1.ForeColor = dlgColorDialog.Color
End Sub
End Class

OUTPUT

ACTIVITY 2 MESSAGE BOX & INPUT BOX


FORM1.VB
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles
Button1.Click
MessageBox.Show("WELCOME EVERYBODY", "WELCOME", MessageBoxButtons.OK)
End Sub
-----------------------------------------------------------------------------------Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles
Button2.Click
InputBox("Please enter your name", "name")
End Sub
End Class

OUTPUT

ACTIVITY 3 CONTROL STRUCTURE


FORM 1.VB
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles
Button1.Click
If RadioButton1.Checked = True Then
TextBox1.Text = "Red"
ElseIf RadioButton2.Checked = True Then
TextBox1.Text = "Green"
ElseIf RadioButton3.Checked = True Then
TextBox1.Text = "Yellow"
End If
If RadioButton4.Checked = True Then
TextBox2.Text = "XL"
ElseIf RadioButton5.Checked = True Then
TextBox2.Text = "L"
ElseIf RadioButton6.Checked = True Then
TextBox2.Text = "M"
ElseIf RadioButton7.Checked = True Then
TextBox2.Text = "S"
End If
End Sub
-----------------------------------------------------------------------------------Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles
Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
End Sub
-----------------------------------------------------------------------------------Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles
Button3.Click
End

End Sub
End Class

Output

Potrebbero piacerti anche