VISUAL BASIC 2010 : 10 PROGRAMAS

Page 1

INSTITUTO TECNOLOGICO SUPERIOR LUIS A.MARTINEZ TUNGURAHUA – AMBATO SEGUNDO ANALISIS DE SISTEMAS

PROGRAMACION ORIENTADA A OBJETOS

LICENCIADA: VERONICA TOAZA

AUTORES JONATHAN TIPANTASIG DIEGO MARTINEZ


ÍNDICE 1 Archivos De Texto 2 Arrastrar y Saltar 3 Explorador De Archivos 4 Navegador Web 5 Juego Laberinto 6 Despertador 7 Calculo De Áreas 8 Convertidor De Horas, Kilómetros y Toneladas 9 Programa Para Calcular El Valor Total Por Número De Pasajeros De Una Cooperativa De Transportes 10 Programa Estadística


ARCHIVOS DE TEXTO.

CODIGO: Public Class MainForm Private filename As String Private Sub openTextFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles openTextFile.Click Try With odlgTextFile .CheckFileExists = True .CheckPathExists = True .DefaultExt = "txt" .DereferenceLinks = True .Filter = _ "Text files (*.txt)|*.txt|All files|*.*" .Multiselect = False .RestoreDirectory = True .ShowHelp = True .ShowReadOnly = False .ReadOnlyChecked = False .Title = "Select a file to open" .ValidateNames = True If .ShowDialog = Windows.Forms.DialogResult.OK Then Try txtFileContents.Text = My.Computer.FileSystem.ReadAllText(.FileName) Catch fileException As Exception Throw fileException


End Try End If End With Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub btnSaveTextFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveTextFile.Click Try With sdlgTextFile .AddExtension = True .CheckPathExists = True .CreatePrompt = False .OverwritePrompt = True .ValidateNames = True .ShowHelp = True .DefaultExt = "txt" .FileName = filename .Filter = _ "Text files (*.txt)|*.txt|" & _ "All files|*.*" .FilterIndex = 1 If .ShowDialog() = Windows.Forms.DialogResult.OK Then My.Computer.FileSystem.WriteAllText(.FileName, txtFileContents.Text, False) End If End With Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub btnSelectColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectColor.Click Static CustomColors() As Integer = _ {RGB(255, 0, 0), RGB(0, 255, 0), RGB(0, 0, 255)} Try With cdlgText .Color = txtFileContents.ForeColor .CustomColors = CustomColors .AllowFullOpen = True .AnyColor = True

.FullOpen = False

.SolidColorOnly = True .ShowHelp = True If .ShowDialog() = Windows.Forms.DialogResult.OK Then txtFileContents.ForeColor = .Color CustomColors = .CustomColors End If cdlgText.Reset() End With

Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try


End Sub Private Sub btnSelectFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSelectFont.Click Try With fdlgText

.Font = txtFileContents.Font .Color = txtFileContents.ForeColor .ShowColor = True .ShowApply = True

.ShowEffects = True . .ShowHelp = True .AllowScriptChange = True .AllowSimulations = False .AllowVectorFonts = False .AllowVerticalFonts = False .FixedPitchOnly = False .FontMustExist = True .MaxSize = 48 .MinSize = 8 If .ShowDialog = Windows.Forms.DialogResult.OK Then txtFileContents.Font = .Font End If End With Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub btnBrowseFolders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBrowseFolders.Click Try With fldlgList .RootFolder = Environment.SpecialFolder.Personal .Description = "Select the directory you want to use as the default." .ShowNewFolderButton = True If .ShowDialog = Windows.Forms.DialogResult.OK Then txtDirectory.Text = .SelectedPath End If End With Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub btnRetriveFileNames_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetriveFileNames.Click Try With odlgFileNames .Reset() .InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Temp .AddExtension = True .CheckFileExists = True .CheckPathExists = True .DefaultExt = "txt" .DereferenceLinks = True


.Filter = _ "Text files (*.txt)|*.txt|" & _ "All files|*.*" .Multiselect = True .RestoreDirectory = True .ShowHelp = True .ShowReadOnly = False .Title = "Select a file" .ValidateNames = True If .ShowDialog() = Windows.Forms.DialogResult.OK Then lstFiles.DataSource = .FileNames End If End With Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click End End Sub Private Sub pgeOpenMultipleFiles_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pgeOpenMultipleFiles.Click End Sub Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class


ARRASTRAR Y SOLTAR

CODIGO: Public Class MainForm Const CtrlMask As Byte = 8 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load picLeft.AllowDrop = True picRight.AllowDrop = True End Sub Private Sub txtSource_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles txtSource.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then txtSource.SelectAll() txtSource.DoDragDrop(txtSource.SelectedText, DragDropEffects.Move Or DragDropEffects.Copy) End If End Sub Private Sub PictureBox_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles picLeft.MouseDown, picRight.MouseDown If e.Button = Windows.Forms.MouseButtons.Left Then Dim pic As PictureBox = CType(sender, PictureBox) ' Invoke the drag and drop operation. If Not pic.Image Is Nothing Then pic.DoDragDrop(pic.Image, DragDropEffects.Move Or DragDropEffects.Copy) End If End If End Sub Private Sub PictureBox_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles picLeft.DragEnter, picRight.DragEnter If (e.Data.GetDataPresent(DataFormats.Bitmap)) Then


If (e.KeyState And CtrlMask) = CtrlMask Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.Move End If Else e.Effect = DragDropEffects.None End If End Sub Private Sub PictureBox_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles picLeft.DragDrop, picRight.DragDrop ' Display the image in the selected PictureBox control. Dim pic As PictureBox = CType(sender, PictureBox) pic.Image = CType(e.Data.GetData(DataFormats.Bitmap), Bitmap)

If (e.KeyState And CtrlMask) <> CtrlMask Then If sender Is picLeft Then picRight.Image = Nothing Else picLeft.Image = Nothing End If End If End Sub Private Sub TreeView_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles tvwLeft.DragDrop, tvwRight.DragDrop ' Initialize variable that holds the node dragged by the user. Dim OriginationNode As TreeNode = CType(e.Data.GetData("System.Windows.Forms.TreeNode"), TreeNode) If e.Data.GetDataPresent("System.Windows.Forms.TreeNode", False) Then Dim pt As Point Dim DestinationNode As TreeNode pt = CType(sender, TreeView).PointToClient(New Point(e.X, e.Y)) DestinationNode = CType(sender, TreeView).GetNodeAt(pt) If DestinationNode IsNot Nothing Then . If Not DestinationNode.TreeView Is OriginationNode.TreeView Then DestinationNode.Nodes.Add(CType(OriginationNode.Clone, TreeNode)) DestinationNode.Expand() If (e.KeyState And CtrlMask) <> CtrlMask Then OriginationNode.Remove() End If End If End If End If End Sub Private Sub TreeView_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles tvwLeft.DragEnter, tvwRight.DragEnter If (e.Data.GetDataPresent("System.Windows.Forms.TreeNode")) Then If (e.KeyState And CtrlMask) = CtrlMask Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.Move End If Else e.Effect = DragDropEffects.None End If End Sub

Private Sub TreeView_ItemDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ItemDragEventArgs) Handles tvwLeft.ItemDrag, tvwRight.ItemDrag If e.Button = Windows.Forms.MouseButtons.Left Then DoDragDrop(e.Item, DragDropEffects.Move Or DragDropEffects.Copy) End If End Sub

Private Sub txtUpperRight_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtAllowDrop.DragEnter If (e.Data.GetDataPresent(DataFormats.Text)) Then If (e.KeyState And CtrlMask) = CtrlMask Then e.Effect = DragDropEffects.Copy Else e.Effect = DragDropEffects.Move End If


Else e.Effect = DragDropEffects.None End If End Sub Private Sub txtAllowDrop_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles txtAllowDrop.DragDrop txtAllowDrop.Text = e.Data.GetData(DataFormats.Text).ToString

If (e.KeyState And CtrlMask) <> CtrlMask Then txtSource.Text = "" End If End Sub Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click Me.Close() End Sub Private Sub txtAllowDrop_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAllowDrop.TextChanged End Sub Private Sub tvwLeft_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvwLeft.AfterSelect End Sub Private Sub picRight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picRight.Click End Sub Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click End Sub End Class


EXPLORADOR

CODIGO: Public Class MainForm Private Sub btnSimple_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Simple.Click Dim sdv As New DirectoryScanner() sdv.Show() End Sub Private Sub btnExplorer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Explorer.Click Dim esfv As New ExplorerStyleViewer() esfv.Show() End Sub Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click Me.Close() End Sub Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class

Imports System.IO Public Class DirectoryScanner Const MB As Long = 1024 * 1024


Private Sub DirectoryScanner_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ListView1.Columns.Add("Size", 90, HorizontalAlignment.Left) ListView1.Columns.Add("Folder Name", 400, HorizontalAlignment.Left) End Sub Private Sub AddToListView(ByVal strSize As String, ByVal strFolderName As String) Dim listViewItem As New ListViewItem() Dim listViewSubItem As ListViewItem.ListViewSubItem listViewItem.Text = strSize listViewItem.ForeColor = GetSizeColor(strSize) listViewSubItem = New ListViewItem.ListViewSubItem() listViewSubItem.Text = strFolderName listViewItem.SubItems.Add(listViewSubItem) ListView1.Items.Add(listViewItem) End Sub Private Function GetSizeColor(ByVal strSize As String) As System.Drawing.Color Return GetSizeColor(CLng(CDbl(strSize.Substring(0, _ strSize.LastIndexOf("M") - 1)) * MB)) End Function Private Function GetSizeColor(ByVal intSize As Long) As System.Drawing.Color Select Case intSize Case 200 * MB To 500 * MB Return System.Drawing.Color.Gold Case Is > 500 * MB Return System.Drawing.Color.Red Case Else Return System.Drawing.Color.Green End Select End Function Public Function GetDirectorySize(ByVal strDirPath As String, _ ByVal dnDriveOrDirectory As DirectoryNode) As Long Try Dim astrSubDirectories As String() = Directory.GetDirectories(strDirPath) Dim strSubDirectory As String For Each strSubDirectory In astrSubDirectories Dim dnSubDirectoryNode As DirectoryNode dnSubDirectoryNode = New DirectoryNode() dnSubDirectoryNode.Text = _ strSubDirectory.Remove(0, strSubDirectory.LastIndexOf("\") + 1) dnDriveOrDirectory.Size += _ GetDirectorySize(strSubDirectory, dnSubDirectoryNode) dnDriveOrDirectory.Nodes.Add(dnSubDirectoryNode) Next Dim astrFiles As String() = Directory.GetFiles(strDirPath) Dim strFileName As String Dim Size As Long = 0 For Each strFileName In astrFiles dnDriveOrDirectory.Size += New FileInfo(strFileName).Length Next dnDriveOrDirectory.ForeColor = _ GetSizeColor(dnDriveOrDirectory.Size) Catch exc As Exception End Try Return dnDriveOrDirectory.Size End Function


Public Sub ShowSubDirectories(ByVal dnDrive As DirectoryNode) Dim strSubDirectory As DirectoryNode ListView1.Items.Clear() For Each strSubDirectory In dnDrive.Nodes AddToListView(Format(strSubDirectory.Size / MB, "F") + "MB", _ strSubDirectory.Text) Next End Sub Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click Me.Close() End Sub Private Sub AllDirectoriesToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AllDirectoriesToolStripMenuItem.Click Me.Cursor = Cursors.WaitCursor Dim drives As String() = Directory.GetLogicalDrives() Dim drive As String TreeView1.Nodes.Clear() ListView1.Items.Clear() For Each drive In drives Dim dnDrive As DirectoryNode Try dnDrive = New DirectoryNode() dnDrive.Text = drive.Remove(Len(drive) - 1, 1) TreeView1.Nodes.Add(dnDrive) dnDrive.Size += GetDirectorySize(drive, dnDrive) Catch exc As Exception End Try Next Me.Cursor = Cursors.Arrow End Sub Private Sub FromOneDirectoryToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FromOneDirectoryToolStripMenuItem.Click Me.Cursor = Cursors.WaitCursor Dim SelectedDirectory As String = FolderBrowser.ShowDialog() Dim SelectedDirectoryNode As DirectoryNode TreeView1.Nodes.Clear() ListView1.Items.Clear() Try SelectedDirectoryNode = New DirectoryNode() SelectedDirectoryNode.Text = SelectedDirectory TreeView1.Nodes.Add(SelectedDirectoryNode) SelectedDirectoryNode.Size += GetDirectorySize(SelectedDirectory, _ SelectedDirectoryNode) Catch exc As Exception End Try Me.Cursor = Cursors.Arrow End Sub Private Sub TreeView1_AfterExpand(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterExpand


e.Node.Expand() ShowSubDirectories(CType(e.Node, DirectoryNode)) End Sub Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect Dim SubDirectory As DirectoryNode = CType(e.Node, DirectoryNode) ListView1.Items.Clear() AddToListView(Format(SubDirectory.Size / (1024 * 1024), "F") + "MB", _ SubDirectory.Text) End Sub Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged End Sub Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked End Sub End Class

Imports System.IO Public Class ExplorerStyleViewer Private dtvwDirectory As DirectoryTreeView Private flvFiles As FileListView Private mivChecked As MenuItemView Sub DirectoryTreeViewOnAfterSelect(ByVal obj As Object, ByVal tvea As TreeViewEventArgs) flvFiles.ShowFiles(tvea.Node.FullPath) End Sub Private Sub ExplorerStyleViewer_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load flvFiles = New FileListView() SplitContainer1.Panel2.Controls.Add(flvFiles) flvFiles.Dock = DockStyle.Fill dtvwDirectory = New DirectoryTreeView() SplitContainer1.Panel1.Controls.Add(dtvwDirectory) dtvwDirectory.Dock = DockStyle.Left AddHandler dtvwDirectory.AfterSelect, _ AddressOf DirectoryTreeViewOnAfterSelect Dim menuView As New ToolStripMenuItem("&View") MenuStrip1.Items.Add(menuView) Dim astrView As String() = {"Lar&ge Icons", "S&mall Icons", "&List", "&Details"} Dim aview As View() = {View.LargeIcon, View.SmallIcon, View.List, View.Details} Dim eh As New EventHandler(AddressOf MenuOnViewSelect) Dim i As Integer For i = 0 To 3 Dim miv As New MenuItemView() miv.Text = astrView(i) miv.View = aview(i) miv.Checked = False AddHandler miv.Click, eh If i = 3 Then mivChecked = miv mivChecked.Checked = True flvFiles.View = mivChecked.View End If menuView.DropDownItems.Add(miv) Next i End Sub


Sub MenuOnViewSelect(ByVal obj As Object, ByVal ea As EventArgs) mivChecked.Checked = False mivChecked = CType(obj, MenuItemView) mivChecked.Checked = True flvFiles.View = mivChecked.View End Sub Private Sub exitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitToolStripMenuItem.Click Me.Close() End Sub Private Sub SplitContainer1_Panel2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer1.Panel2.Paint End Sub Private Sub MenuStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles MenuStrip1.ItemClicked End Sub End Class


NAVEGADOR WEB

CODIGO: Imports System.Xml Public Class Browser Friend WithEvents tsbWebSite1 As System.Windows.Forms.ToolStripButton Dim xmldoc As New XmlDocument Private Sub GoToUrl(ByVal sWebsite As String) Dim xPath As String = "//WebSite[Name='" & sWebsite & "']/URL" Dim xn As XmlNode = xmldoc.SelectSingleNode(xPath) WebBrowser1.Url = New Uri(xn.InnerText) End Sub Private Sub tsbBack_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbBack.Click WebBrowser1.GoBack() End Sub Private Sub tsbForward_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbForward.Click WebBrowser1.GoForward() End Sub


Private Sub tsbHome_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbHome.Click WebBrowser1.GoHome() End Sub Private Sub tsbRefresh_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbRefresh.Click WebBrowser1.Refresh() End Sub Private Sub tsbManage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbManage.Click Dim frmManage As New Sites frmManage.ShowDialog() AddToolStripButtons() End Sub Private Sub frmBrowser_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load AddToolStripButtons() End Sub Private Sub AddTSButton(ByVal buttonName As String, ByVal webSiteName As String) Dim newbutton As New System.Windows.Forms.ToolStripButton newbutton.Name = buttonName newbutton.Text = webSiteName newbutton.DisplayStyle = ToolStripItemDisplayStyle.Text ToolStrip3.Items.Add(newbutton) AddHandler newbutton.Click, AddressOf tsbutton_Click End Sub Private Sub AddToolStripButtons() xmldoc.Load(My.Application.Info.DirectoryPath & "\" & My.Settings.XmlFileName) ToolStrip3.Items.Clear() Dim websiteNodes As XmlNodeList Dim webSiteNode As XmlNode websiteNodes = xmldoc.GetElementsByTagName("WebSite") Dim iCount As Integer = 1 For Each webSiteNode In websiteNodes Dim eachSiteNodes As XmlNodeList Dim eachSiteNode As XmlNode eachSiteNodes = webSiteNode.ChildNodes For Each eachSiteNode In eachSiteNodes If eachSiteNode.Name = "Name" Then AddTSButton("tsWebsite" & iCount.ToString, eachSiteNode.InnerText) iCount += 1 End If Next Next End Sub Private Sub tsbutton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim aButton As ToolStripButton = CType(sender, ToolStripButton) GoToUrl(aButton.Text) End Sub Private Sub tsbMSDN_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbMSDN.Click WebBrowser1.Url = New Uri("http://msdn.microsoft.com") End Sub


Private Sub tsbVisualBasic_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbVisualBasic.Click WebBrowser1.Url = New Uri("http://msdn.microsoft.com/vbasic") End Sub Private Sub tsbVisualStudio_DisplayStyleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbVisualStudio.DisplayStyleChanged WebBrowser1.Url = New Uri("http://msdn.microsoft.com/vstudio") End Sub Private Sub tsbGo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbGo.Click Try WebBrowser1.Url = New Uri(txtUrl.Text) Catch MsgBox End Try End Sub End Class


JUEGO LABERINTO

NIVEL 1

NIVEL 2

NIVEL 3


NIVEL 4

CODIGO: Public Class Escullir Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Nivell1.Show() End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Nivell2.Show() End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Nivell3.Show() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Nivell4.Show() End Sub Private Sub Escullir_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class Public Class Nivell1 Public Sub New() InitializeComponent() MoveToStart() End Sub Private Sub MoveToStart() Dim StartingPoint = Panel1.Location() StartingPoint.Offset(10, 10) Cursor.Position = PointToScreen(StartingPoint) End Sub Private Sub Wall_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.MouseEnter, Panel1.MouseEnter, Label8.MouseEnter, Label7.MouseEnter, Label6.MouseEnter,


Label5.MouseEnter, Label46.MouseEnter, Label45.MouseEnter, Label44.MouseEnter, Label43.MouseEnter, Label42.MouseEnter, Label41.MouseEnter, Label4.MouseEnter, Label37.MouseEnter, Label36.MouseEnter, Label35.MouseEnter, Label33.MouseEnter, Label32.MouseEnter, Label31.MouseEnter, Label30.MouseEnter, Label29.MouseEnter, Label28.MouseEnter, Label27.MouseEnter, Label26.MouseEnter, Label25.MouseEnter, Label24.MouseEnter, Label23.MouseEnter, Label2.MouseEnter, Label18.MouseEnter, Label17.MouseEnter, Label16.MouseEnter, Label15.MouseEnter, Label14.MouseEnter, Label13.MouseEnter, Label12.MouseEnter, Label11.MouseEnter, Label10.MouseEnter, Label1.MouseEnter MoveToStart() End Sub Private Sub Form1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label39.MouseEnter, Label9.MouseEnter MoveToStart() End Sub Private Sub Form1_MouseEnter1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label22.MouseEnter Nivell2.Show() MsgBox("Muy Bien") End Sub Private Sub Form1_MouseEnter2(ByVal sender As Object, ByVal e As System.EventArgs) End Sub Private Sub Nivell1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Label60_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label60.Click End Sub End Class

Public Class Nivell2 Public Sub New() InitializeComponent() MoveToStart() End Sub Private Sub Final_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) End Sub Private Sub MoveToStart() Dim StartingPoint = Panel1.Location() StartingPoint.Offset(10, 10) Cursor.Position = PointToScreen(StartingPoint) End Sub Private Sub Wall_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.MouseEnter


End Sub Private Sub Form1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label39.MouseEnter, Label9.MouseEnter MoveToStart() End Sub Private Sub Form2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label22.MouseEnter MsgBox("Molt bé!") Nivell3.Show() End Sub Private Sub Nivell2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class

Public Class Nivell3 Public Sub New() InitializeComponent() MoveToStart() End Sub Private Sub Final_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) End Sub Private Sub MoveToStart() Dim StartingPoint = Panel1.Location() StartingPoint.Offset(10, 10) Cursor.Position = PointToScreen(StartingPoint) End Sub Private Sub Wall_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Panel1.MouseEnter, Label45.MouseEnter, Label37.MouseEnter, Label11.MouseEnter, Label10.MouseEnter MoveToStart() End Sub Private Sub Form1_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) MoveToStart() End Sub Private Sub Form2_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label22.MouseEnter MsgBox("Molt bé!") Close() End Sub Private Sub Nivell3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class Public Class Nivell4 Public Sub New() InitializeComponent()


MoveToStart() End Sub Private Sub MoveToStart() Dim StartingPoint = Panel1.Location() StartingPoint.Offset(10, 10) Cursor.Position = PointToScreen(StartingPoint) End Sub Private Sub Label30_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label9.MouseEnter, Label8.MouseEnter, Label7.MouseEnter, MoveToStart() End Sub Private Sub Label22_MouseEnter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label22.MouseEnter Escullir.Show() End Sub Private Sub Nivell4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class


DESPETADOR. .

CODIGO: Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, btncarga.Click lbwakeup.Text = "Primera alarma" btncarga.Visible = False btnWakeup.Visible = True End Sub

Private Sub btnWakeup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnWakeup.Click mtTime.Enabled = False btncarga.Visible = True btnWakeup.Visible = False End Sub Private Sub btncarga_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) mtTime.Enabled = True btncarga.Visible = False btnWakeup.Visible = True End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim hr As String = TimeOfDay.Hour If hr.Length = 1 Then hr = "0" + hr End If Dim mn As String = TimeOfDay.Minute If mn.Length = 1 Then mn = "0" + mn End If Dim sc As String = TimeOfDay.Second If sc.Length = 1 Then sc = "0" + sc End If lbwakeup.Text = hr + ":" + mn + ":" + sc If mtTime.Text = lbwakeup.Text Then MessageBox.Show("YA AMANECIO !!!!") End If End Sub End Class


CALCULO DE AREAS.

CODIGO: Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim area, base, altura As Double base = Val(TextBox1.Text) altura = Val(TextBox2.Text) area = (base * altura) / 2 TextBox3.Text = area TextBox3.Text = (Val(TextBox1.Text) * Val(TextBox2.Text)) / 2 End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim l, area As Integer l = TextBox4.Text area = l * l TextBox5.Text = area End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim a As Double Dim b As Double Dim area As Double a = TextBox6.Text b = TextBox7.Text area = a * b TextBox8.Text = Trim(area) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click


Dim base_mayor, base_menor, altura, area As Double base_menor = Val(TextBox15.Text) base_mayor = Val(TextBox14.Text) altura = Val(TextBox13.Text) area = ((base_menor + base_mayor) / 2) * altura TextBox12.Text = area End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click End End Sub Private Sub btncalcular_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalcular.Click Dim radio, resultado As Integer radio = Val(txtradio.Text) resultado = 3.1416 * (radio * radio) txtresultado.Text = resultado End Sub Private Sub btnlimpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlimpiar.Click TextBox1.Text = "" TextBox2.Clear() TextBox3.Text = "" TextBox1.Focus() TextBox4.Clear() TextBox2.Clear() TextBox5.Text = "" TextBox4.Focus() TextBox6.Text = "" TextBox7.Clear() TextBox8.Text = "" TextBox6.Focus() TextBox13.Text = "" TextBox14.Text = "" TextBox15.Clear() TextBox12.Text = "" TextBox14.Focus() txtradio.Clear() txtresultado.Text = "" txtradio.Focus() End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class


CONVERTIDOR DE HORAS, KILOMETROS, TONELADAS.

CODIGO: Public Class Form1 Private Sub btncomvertir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncomvertir.Click Dim horas, minutos, segundos As String horas = txthoras.Text Dim comvertidor minutos = txtminu.Text segundos = txtsegu.Text comvertidor = btncomvertir.Text minutos = horas * 60 segundos = minutos * 60 txtminu.Text = minutos txtsegu.Text = segundos End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End End Sub Private Sub btnconvertirk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnconvertirk.Click Dim kilometros, metros, centimetros As String kilometros = txtkm.Text Dim comvertidor metros = txtm.Text centimetros = txtcm.Text comvertidor = btnconvertirk.Text metros = kilometros * 1000


centimetros = metros * 100 txtm.Text = metros txtcm.Text = centimetros End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim toneladas, kilogramos, libras, gramos As String toneladas = txttn.Text Dim comvertidor kilogramos = txtkg.Text libras = txtlb.Text gramos = txtgr.Text comvertidor = Button2.Text kilogramos = toneladas * 97.2 libras = kilogramos * 2000 gramos = libras * 453.6 txtkg.Text = kilogramos txtlb.Text = libras txtgr.Text = gramos End Sub Private Sub GroupBox2_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox2.Enter End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub

Private Sub btnlimpiar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnlimpiar.Click txthoras.Text = "" txtminu.Text = "" txtsegu.Clear() txthoras.Focus() txtkm.Text = "" txtm.Text = "" txtcm.Clear() txtkm.Focus() txttn.Text = "" txtkg.Text = "" txtlb.Text = "" txtgr.Clear() txttn.Focus() End Sub End Class


PROGRAMA PARA CALCULAR EL VALOR TOTAL POR NUMERO DE PASAJEROS DE UNA COOPERATIVA DE TRANSPORTES.

CODIGO: Public Class Form1 Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click End Sub Private Sub btncalc1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalc1.Click Dim busa As Double Dim calc1 As String busa = txtbusa.Text calc1 = btncalc1.Text

If busa >= 30 Then MsgBox("El total a pagar es: " & busa * 3.5 & " $ y cada persona debe pagar: 3.50 $") Else MsgBox(" El total a pagar es: " & busa * 3.0 & " $ y cada persona debe pagar: 3.00 $") End If End Sub Private Sub btncalc2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalc2.Click Dim busb As Double Dim calc2 As String busb = txtbusb.Text


calc2 = btncalc2.Text If busb >= 40 Then MsgBox("El total a pagar es: " & busb * 4.25 & " $ y cada persona debe pagar: 4.25 $") Else MsgBox(" El total a pagar es: " & busb * 4.5 & " $ y cada persona debe pagar: 4.50 $") End If End Sub Private Sub btncalc3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncalc3.Click Dim busc As Double Dim calc3 As String busc = txtbusb.Text calc3 = btncalc3.Text If busc >= 50 Then MsgBox("El total a pagar es: " & busc * 5.0 & " $ y cada persona debe pagar: 5.00 $") Else MsgBox(" El total a pagar es: " & busc * 5.0 & " $ y cada persona debe pagar: 5.00 $") End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click txtbusa.Text = "" txtbusb.Text = "" txtbusc.Text = "" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click End End Sub Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click End Sub End Class


PROGRAMA DE ESTADISTICA.

CODIGO: Public Class Form1 Private Sub btnsuma_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsuma.Click Dim rojo, azul, verde, blanco, suma As Double rojo = Val(txtrojo.Text) azul = Val(txtazul.Text) verde = Val(txtverde.Text) blanco = Val(txtblanco.Text) suma = (rojo + azul + verde + blanco) txtsuma.Text = Val(txtrojo.Text) + Val(txtazul.Text) + Val(txtverde.Text) + Val(txtblanco.Text) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TextBox1.Text = Val(txtrojo.Text) + Val(txtverde.Text) / txtsuma.Text End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox2.Text = txtsuma.Text - Val(txtazul.Text) - Val(txtblanco.Text) / txtsuma.Text End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox3.Text = txtsuma.Text - Val(txtblanco.Text) / txtsuma.Text End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click TextBox4.Text = Val(txtrojo.Text) + Val(txtazul.Text) + Val(txtverde.Text) / txtsuma.Text End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click txtrojo.Text = ""


txtazul.Text = "" txtverde.Text = "" txtblanco.Text = "" txtsuma.Text = "" TextBox1.Text = "" TextBox2.Text = "" TextBox3.Text = "" TextBox4.Text = "" End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click TextBox1.Text = Math.Round(Convert.ToDouble(TextBox1.Text), 2) & "%" TextBox2.Text = Math.Round(Convert.ToDouble(TextBox2.Text), 2) & "%" TextBox3.Text = Math.Round(Convert.ToDouble(TextBox3.Text), 2) & "%" TextBox4.Text = Math.Round(Convert.ToDouble(TextBox4.Text), 2) & "%" End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click End End Sub End Class



Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.