0% found this document useful (0 votes)
61 views9 pages

Public Class Private Sub As Object As Handles Mybase Dim As Integer

The document contains 5 code examples that demonstrate using Visual Basic .NET to perform various numeric calculations and display results in a Windows form application. Each code example shows initializing variables, getting user input, performing calculations in a loop, and displaying output in labels, textboxes or a listbox. The examples calculate sums, products, and display patterns of characters based on user-provided numeric values.

Uploaded by

Sara Victoria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views9 pages

Public Class Private Sub As Object As Handles Mybase Dim As Integer

The document contains 5 code examples that demonstrate using Visual Basic .NET to perform various numeric calculations and display results in a Windows form application. Each code example shows initializing variables, getting user input, performing calculations in a loop, and displaying output in labels, textboxes or a listbox. The examples calculate sums, products, and display patterns of characters based on user-provided numeric values.

Uploaded by

Sara Victoria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

1-Public Class Form1

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


Dim cn As Integer = 0
Label1.Text = "numeros impares sumatoria de 1 al 100"
Label2.Text = "suma de numeros impares"
Label3.Text = "total de numeros impares"
Button1.Text = "mostrar"
End Sub

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


Button1.Click

Dim cn As Integer = 0
Dim ac As Integer
Dim sum As Integer = 0
Dim tot As Integer = 0
Do While (cn < 100)
ac = ac + 1
cn = cn + 1
tot = ac / 2
sum = sum + (cn / 2)

ListBox1.Items.Add(ac)

Loop

TextBox1.Text = sum
TextBox2.Text = tot
End Sub
End Class
2
Public Class Form1
Dim i As Integer
Dim f As Integer
Dim vc As Integer = 0

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


Button1.Click
While i <= f
If i Mod 2 = 0 Then
ListBox1.Items.Add(i)
End If
i = i + 1
End While

End Sub

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


Button2.Click
i = InputBox("INTRODUCE EL PRIMER VALOR", "MENSAJE")
f = InputBox("INTRODUCE EL SEGUNDO VALOR", "MENSAJE")
If f < i Then
MsgBox("NUMEROS INCORRECTOS, INGRESA DE NUEVO LOS VALORES", vbCritical,
"ERROR")
End If
End Sub
End Class
3
Public Class Form1
Dim v1, v2 As Integer
Dim vc As Integer = 0
Dim suma As Integer

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


Button2.Click
While v1 <= v2
If v1 Mod 1 = 0 Then
ListBox1.Items.Add(v1)
End If
suma = suma + v1
v1 = v1 + 1
End While
TextBox1.Text = suma
End Sub

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


Button1.Click
v1 = InputBox("introduce el primer valor numerico", "mensaje")
v2 = InputBox("introduce el segundo valor numerico", "mensaje")
If v2 < v1 Then
MsgBox("numeros invalidos, intenta de nuevo", vbCritical, "error")
End If
End Sub
End Class
4
Public Class Form1
Dim v1, v2 As Integer
Dim multi As Integer
Dim vc As Integer = multi

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


Button2.Click
v1 = InputBox("introduce el primer valor numerico", "mensaje")
v2 = InputBox("introduce el segundo valor numerico", "mensaje")
If v2 < v1 Then
MsgBox("numeros invalidos, intenta de nuevo", vbCritical, "error")
End If
End Sub

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


Button1.Click
While v1 <= v2
If v1 Mod 1 = 0 Then
ListBox1.Items.Add(v1)
End If
multi = (multi * v1)
v1 = v1 + 1
End While
TextBox1.Text = multi
End Sub
End Class

5
Public Class Form1
Dim a As Integer
Dim vc As Integer = 0

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

End Sub

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


Button1.Click
a = InputBox("introduce un valor numerico", "hola")
While vc < a
ListBox1.Items.Add("*")
vc = vc + 1
End While

End Sub
End Class

You might also like