0% found this document useful (0 votes)
18 views11 pages

Martinez Rodriguez Mirna Angelica Ejercicio 1: Public Class Private Sub As Object As Handles Mybase

This document contains 10 coding exercises in Visual Basic .NET. Each exercise contains code to create a form with labels, text boxes, buttons, and other controls to accept user input and perform calculations or conditional logic. The code samples demonstrate concepts like event handling, conditional statements, arithmetic operations, and displaying results to the user.

Uploaded by

Mirna Martinez
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)
18 views11 pages

Martinez Rodriguez Mirna Angelica Ejercicio 1: Public Class Private Sub As Object As Handles Mybase

This document contains 10 coding exercises in Visual Basic .NET. Each exercise contains code to create a form with labels, text boxes, buttons, and other controls to accept user input and perform calculations or conditional logic. The code samples demonstrate concepts like event handling, conditional statements, arithmetic operations, and displaying results to the user.

Uploaded by

Mirna Martinez
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/ 11

Martinez Rodriguez Mirna Angelica

Ejercicio 1
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = "EXPRECION ALGORITMICA"
Label2.Text = "Y= A*B - (C/ (D+E))"
Label3.Text = " DATOS"
Label4.Text = "A ="
Label5.Text = "B ="
Label6.Text = "C ="
Label7.Text = "D ="
Label8.Text = "E ="
Label9.Text = "Y="
TextBox6.Enabled = False
Button1.Text = "CALCULAR"
Button2.Text = "LIMPIAR"
Me.BackColor = Color.LightBlue
End Sub

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


Button1.Click
TextBox6.Text = CDbl(TextBox1.Text) * CDbl(TextBox2.Text) -
(CDbl(TextBox3.Text) / (CDbl(TextBox4.Text) + CDbl(TextBox5.Text)))
End Sub

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


Button2.Click
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
TextBox6.Clear()

End Sub
End Class
Ejercicio 2
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a As Double
a = TextBox1.Text
If (a >= 1000) Then
a = a * 2.5
Label5.Text = a
Else
a = a * 4
Label5.Text = a

End If
End Sub

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


Button2.Click
TextBox1.Clear()
Label5.Text = ""
TextBox1.Focus()
End Sub
End Class
Ejercicio 3
Public Class Form1
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
Dim a, des As Double
a = TextBox1.Text
If (a > 2500) Then
des = a * 0.15
a = a - des
Label8.Text = TextBox1.Text
Label9.Text = des
Label10.Text = a

Else
des = a * 0.08
a = a - des
Label8.Text = TextBox1.Text
Label9.Text = des
Label10.Text = a

GroupBox2.Visible = True

End If
End Sub

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


Button2.Click
TextBox1.Clear()
GroupBox2.Visible = False
TextBox1.Focus()

End Sub
End Class

Ejercicio 4
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a As Double
a = Val(TextBox1.Text)

If (a > 200) Then


a = a * 75
Label6.Text = a
Else
a = a * 80
Label6.Text = a
End If
GroupBox2.Visible = True

End Sub

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


Button2.Click
TextBox1.Clear()
GroupBox2.Visible = False
TextBox1.Focus()

End Sub
End Class
Ejercicio 5
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a, b, des As Double
a = Val(TextBox1.Text)
b = Val(TextBox2.Text)
If (a > 5) Then
des = b * 0.05
Label8.Text = des
Label9.Text = (b - des) * 0.16
Label10.Text = CDbl(b - des) + CDbl(Label9.Text)
Else
Label8.Text = "0"
Label9.Text = (b - des) * 0.16
Label10.Text = CDbl(b - des) + CDbl(Label9.Text)
End If
GroupBox2.Visible = True
End Sub

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


Button2.Click
TextBox1.Clear()
TextBox2.Clear()
GroupBox2.Visible = False
TextBox1.Focus()

End Sub
End Class
Ejercicio 6
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a As Double
a = Val(TextBox1.Text)
If (a > 30) Then
Label5.Text = a * 95
Else
Label5.Text = "3500"
End If
GroupBox2.Visible = True

End Sub

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


Button2.Click
TextBox1.Clear()
GroupBox2.Visible = False
TextBox1.Focus()

End Sub
End Class
Ejercicio 7
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
Dim a, b, c As Double
a = Val(TextBox1.Text)

If (a <= 5) Then

Else
If (a <= 8) Then
a = ((a - 5) * 0.8) + 5
Else
If (a > 8) Then
a = 4
End If
End If
End If
If (RadioButton1.Checked = True) Then
b = a + (a * 0.03)
Label3.Visible = True
Label3.Text = b
Else
If (RadioButton2.Checked = True) Then
b = a + (a * 0.15)
Label3.Visible = True
Label3.Text = b
End If
End If
GroupBox2.Visible = True

End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles
Button2.Click
TextBox1.Clear()
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton1.Enabled = True
RadioButton2.Enabled = True
GroupBox2.Visible = False
TextBox1.Focus()
End Sub
End Class

Ejercicio 8
Public Class Form1

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


Button1.Click

GroupBox2.Visible = True
If (RadioButton1.Checked = True) Then
Label6.Text = 2 * TextBox2.Text
Else

Label6.Text = 2.5 * TextBox2.Text

End If
End Sub

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


Button2.Click
TextBox2.Clear()
GroupBox2.Visible = False
TextBox2.Focus()
RadioButton1.Checked = False
RadioButton2.Checked = False

End Sub

End Class

Ejercicio 9
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
GroupBox3.Visible = True
Dim a, tar As Double
a = Val(TextBox1.Text)
If (RadioButton1.Checked = True) Then
a = a * 20
Label3.Text = a
If (RadioButton3.Checked = True) Then
Label3.Text = a
Else
tar = a * 0.05
Label3.Text = a + tar
End If

End If
If (RadioButton2.Checked = True) Then
a = a * 25
Label3.Text = a
If (RadioButton3.Checked = True) Then
Label3.Text = a
Else
tar = a * 0.5
Label3.Text = a + tar
End If
End If
End Sub

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


Button2.Click
TextBox1.Clear()
GroupBox3.Visible = False
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
RadioButton4.Checked = False
TextBox1.Focus()

End Sub
End Class

Ejercicio 10
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
GroupBox2.Visible = True
Label3.Visible = True
Dim a As Double
a = Val(TextBox1.Text)
If (a <= 5000) Then
If (RadioButton1.Checked = True) Then
Label4.Text = a * 11
End If

If (RadioButton2.Checked = True) Then


Label4.Text = a * 10
End If
If (RadioButton3.Checked) Then
Label4.Text = a * 12
End If

Else
Label3.Visible = False
Label4.Text = "SU PAQUETE FUE RECHAZADO POR PESO"

End If
End Sub

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


Button2.Click
RadioButton1.Checked = False
RadioButton2.Checked = False
RadioButton3.Checked = False
TextBox1.Clear()
TextBox1.Focus()
GroupBox2.Visible = False
End Sub
End Class

You might also like