This document contains the code for a Windows form application with multiple buttons. Each button click event calls a for loop that performs a calculation based on the number entered in txtNum.text and adds the results to the lstNum list. It calculates a sum variable and displays it in the lblSuma label after each loop completes. It also contains an event handler for clearing the form fields and list when the btnNuevo button is clicked.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
4 views
Codigo
This document contains the code for a Windows form application with multiple buttons. Each button click event calls a for loop that performs a calculation based on the number entered in txtNum.text and adds the results to the lstNum list. It calculates a sum variable and displays it in the lblSuma label after each loop completes. It also contains an event handler for clearing the form fields and list when the btnNuevo button is clicked.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
Public Class Form1
Private Sub CALCULAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles CALCULAR.Click Dim i, num, suma As Integer num = 2 For i = 1 To txtNum.Text lstNum.Items.Add(num) suma = suma + num num = num + 2 Next lblSuma.Text = "La suma :" + suma.ToString End Sub Private Sub lstNum_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstNum.SelectedIndexChanged End Sub Private Sub btnNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNuevo.Click lstNum.Items.Clear() txtNum.Text = "" lblSuma.Text = "" End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click Dim i, num, suma As Double num = -2 For i = 1 To txtNum.Text lstNum.Items.Add(num + 102) suma = suma + (num + 102) num = num - 2 Next lblSuma.Text = "La suma :" + suma.ToString End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click Dim i, num, suma As Double num = 2 For i = 1 To txtNum.Text lstNum.Items.Add(1 / num) suma = suma + 1 / num num = num + 2 Next lblSuma.Text = "La suma :" + suma.ToString End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim i, num, suma As Integer num = 2 For i = 1 To txtNum.Text lstNum.Items.Add((2 * num - 1) / ((num - 1) * 4)) suma = suma + ((2 * num - 1) / ((num - 1) * 4)) num = num + 1 Next lblSuma.Text = "La suma :" + suma.ToString End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click Dim i, num, suma, d As Integer num = 1 For i = 1 To txtNum.Text lstNum.Items.Add(num & " / " & d) If (num Mod 2 = 0) Then num = (num + 1) Else num = (num + 1) * (-1) End If Next lblSuma.Text = "La suma :" + suma.ToString End Sub End Class