This document contains the code for a Windows form application written in Visual Basic. It defines variables and event handlers for text boxes, buttons, and rich text boxes. The application allows the user to enter two arrays of numbers, perform arithmetic operations on them, and display the results. It handles input validation, enabling/disabling of buttons, clearing fields, and confirms exit.
This document contains the code for a Windows form application written in Visual Basic. It defines variables and event handlers for text boxes, buttons, and rich text boxes. The application allows the user to enter two arrays of numbers, perform arithmetic operations on them, and display the results. It handles input validation, enabling/disabling of buttons, clearing fields, and confirms exit.
Direitos autorais:
Attribution Non-Commercial (BY-NC)
Formatos disponíveis
Baixe no formato DOC, PDF, TXT ou leia online no Scribd
This document contains the code for a Windows form application written in Visual Basic. It defines variables and event handlers for text boxes, buttons, and rich text boxes. The application allows the user to enter two arrays of numbers, perform arithmetic operations on them, and display the results. It handles input validation, enabling/disabling of buttons, clearing fields, and confirms exit.
Direitos autorais:
Attribution Non-Commercial (BY-NC)
Formatos disponíveis
Baixe no formato DOC, PDF, TXT ou leia online no Scribd
Private A(10), B(10) As Short Private C(10) As Single Private n As Byte Private Sub txtd1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtd1.KeyPress Select Case Asc(e.KeyChar) Case 8, 48 To 57 Case 13 btn1.PerformClick() Case Else e.Handled = True End Select End Sub Private Sub txtd1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtd1.TextChanged If txtd1.Text <> "" Then btn1.Enabled = True Else btn1.Enabled = False End If End Sub Private Sub txtd2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtd2.KeyPress Select Case Asc(e.KeyChar) Case 8, 48 To 57 Case 13 btn2.PerformClick() Case Else e.Handled = True End Select End Sub Private Sub txtd2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtd2.TextChanged If txtd2.Text <> "" Then btn2.Enabled = True Else btn2.Enabled = False End If End Sub Private Sub btn1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.Click n = n + 1 A(n) = Val(txtd1.Text) rtb1.Text = rtb1.Text & A(n) & " " txtd1.Clear() If n = 10 Then txtd1.Enabled = False n = 0 txtd2.Focus() Else txtd1.Focus() Me.txtd1.BackColor = Color.LightBlue End If End Sub Private Sub btn2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.Click n = n + 1 B(n) = Val(txtd2.Text) rtb2.Text = rtb2.Text & B(n) & " " txtd2.Clear() If n = 10 Then txtd2.Enabled = False n = 0 ActivarBotones() Else txtd2.Focus() Me.txtd2.BackColor = Color.LightGreen End If End Sub Private Sub ActivarBotones() Dim x As Control For Each x In GroupBox1.Controls If TypeOf x Is Button Then x.Enabled = True End If Next End Sub Private Sub Operar(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btns.Click, btnr.Click, btnM.Click, btnD.Click Select Case sender.Name Case "btns" Sumar() Case "btnr" Restar() Case "btnM" Multiplicar() Case "btnD" Dividir() End Select End Sub Private Sub Sumar() Dim I As Byte rtb3.Clear() For I = 1 To 10 C(I) = A(I) + B(I) rtb3.Text = rtb3.Text & C(I) & " " Next End Sub Private Sub Restar() Dim I As Byte rtb3.Clear() For I = 1 To 10 C(I) = A(I) - B(I) rtb3.Text = rtb3.Text & C(I) & " " Next End Sub Private Sub Multiplicar() Dim I As Byte rtb3.Clear() For I = 1 To 10 C(I) = A(I) * B(I) rtb3.Text = rtb3.Text & C(I) & " " Next End Sub Private Sub Dividir() Dim I As Byte rtb3.Clear() For I = 1 To 10 If B(I) <> 0 Then C(I) = Math.Round(A(I) / B(I), 1) rtb3.Text = rtb3.Text & C(I) & " " Else C(I) = 0 End If Next End Sub Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click rtb1.Clear() rtb2.Clear() rtb3.Clear() n = 0 For i As Byte = 0 To 10 A(i) = 0 B(i) = 0 C(i) = 0
Next txtd1.Enabled = True txtd2.Enabled = True txtd1.Focus() End Sub
Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSalir.Click Me.Close() End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As
System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Dim resp As Integer resp = MsgBox("¿Desea Salir del Sistema?", MsgBoxStyle.Question + MsgBoxStyle.YesNo) If resp = MsgBoxResult.No Then e.Cancel = True