You are on page 1of 11

UNIDAD 1

PASO 2 APLICAR HERRAMIENTAS BSICAS PARA


PROGRAMAR AMBIENTE .NET

VISUAL BASIC AVANZADO

UNIVERSIDAD NACIONAL ABIERTA Y A DISTANCIA


CEAD JOSE ACEVEDO Y GOMEZ
INGENIERIA DE SISTEMAS
BOGOTA D.C
2017

INTRODUCTION

In this activity we will design and apply the management of basic tools and their
properties which must be done 5 exercises by students where we will handle text boxes,
button images etc. We will begin to implement what is known in the first activity and
put into practice.
OBJECTIVE

Practice what you learned in Unit 1 with the requested exercises, use the toolbox to
interact with the application, use text boxes, labels, buttons, images, mouse handling
which we will learn to use with each exercise performed.
1. Programa que en dos cuadros de texto reciba solo nmeros en uno y en el otro
reciba solo texto en mayscula. Que valide los intentos de ingreso hasta 3 y
bloquee ocultando los cuadros de texto.

CDIGO Y PROCEDIMIENTO DEL EJERCICIO 1


Public Class Form1

Dim contador = 0

Public Sub TextBox1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox1.KeyPress

If Not IsNumeric(e.KeyChar) Then

e.Handled = True

If Char.IsDigit(e.KeyChar) Then

e.Handled = False

ElseIf Char.IsControl(e.KeyChar) Then

e.Handled = False

ElseIf Char.IsSeparator(e.KeyChar) Then

e.Handled = False

Else

If MsgBox("digitar numero") Then

contador = contador + 1

If contador = 3 Then

MsgBox("limite superado")

TextBox1.Enabled = False

TextBox2.Enabled = False
End If

End If

End If

End If

End Sub

Private Sub TextBox2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


TextBox2.KeyPress

TextBox2.CharacterCasing = CharacterCasing.Upper

If Not Char.IsLetter(e.KeyChar) Then

e.Handled = True

If Char.IsLetter(e.KeyChar) Then

e.Handled = False

ElseIf Char.IsControl(e.KeyChar) Then

e.Handled = False

ElseIf Char.IsSeparator(e.KeyChar) Then

e.Handled = False

Else

If MsgBox("digitar solo texto") Then

contador = contador + 1
If contador = 3 Then

MsgBox("limite superado")

TextBox1.Enabled = False

TextBox2.Enabled = False

End If

End If

End If

End If

End Sub

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

Me.Close()

End Sub

End Class

2. Disee un programa que permita realizar operaciones con fraccionarios. Se debe


explicar en un texto como funciona cada una de las operaciones con un ejemplo.
Cada ejercicio debe estar en un formulario diferente. Que le permita validar
operaciones no vlidas. Como por ejemplo cero o datos no numricos.
Suma y resta con el mismo denominador
Suma y resta con distinto denominador
Multiplicacin de fracciones
Divisin de fracciones

CDIGO Y PROCEDIMIENTO DEL EJERCICIO 2

Public Class Form1


Private Sub Label1_Click(sender As Object, e As EventArgs) Handles Label1.Click
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.Close()
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
'multiplicacin
res1.Text = Val(num1.Text) * Val(num2.Text)
res2.Text = Val(deno2.Text) * Val(deno1.Text)
End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click


'Division
res1.Text = Val(num1.Text) * Val(deno2.Text)
res2.Text = Val(num2.Text) * Val(deno1.Text)

End Sub

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


'suma
If (Val(deno1.Text) = (deno2.Text)) Then
res1.Text = Val(num1.Text) + Val(num2.Text)
res2.Text = Val(deno1.Text)
Else
res1.Text = (Val(num1.Text) * Val(deno2.Text)) + (Val(deno2.Text) *
Val(deno1.Text))
res2.Text = Val(deno1.Text) * Val(deno2.Text)

End If

End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
'resta
If (Val(deno1.Text) = (deno2.Text)) Then
res1.Text = Val(num1.Text) - Val(num2.Text)
res2.Text = Val(deno1.Text)
Else
res1.Text = (Val(num1.Text) * Val(deno2.Text)) - (Val(deno2.Text) *
Val(deno1.Text))
res2.Text = Val(deno2.Text) * Val(deno1.Text)

End If

End Sub

Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click

res1.Text = ""
num1.Text = ""
num2.Text = ""
deno2.Text = ""
deno1.Text = ""
res2.Text = ""
End Sub
Private Sub num1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
num1.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub
Private Sub num2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles
num2.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub

Private Sub deno1_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


deno1.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub

Private Sub deno2_KeyPress(sender As Object, e As KeyPressEventArgs) Handles


deno2.KeyPress
If Not IsNumeric(e.KeyChar) Then
e.Handled = True
End If
End Sub
End Class

CONCLUTION

Unit 1 was reviewed in putting into practice all the learned and implemented the
acquired knowledge which was put into practice with the exercises performed of the
second activity, it was possible to deepen the topics based on the toolbox and its
properties.

BIBLIOGRAPHIC REFERENCES

http://jenelenet.blogspot.com.co/2011/07/limpiar-cajas-de-texto-en-visual-basic.html
http://www.estudiantes.info/matematicas/suma_de_fracciones.htm
https://msdn.microsoft.com/en-us/library/bx185bk6.aspx

You might also like