0% found this document useful (0 votes)
37 views

Formularios Visual Basic

The document contains code for 4 forms (Formulario 1-4) in Visual Basic.NET. Formulario 1 contains code to generate a descending number series and asterisk pattern. Formulario 2 contains code to solve quadratic equations. Formulario 3 contains code to perform basic math operations or factorials and exponents on two input values. Formulario 4 contains code to analyze a sentence for palindromic words, numbers/words, or convert Roman numerals to Arabic numbers.

Uploaded by

Denise
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)
37 views

Formularios Visual Basic

The document contains code for 4 forms (Formulario 1-4) in Visual Basic.NET. Formulario 1 contains code to generate a descending number series and asterisk pattern. Formulario 2 contains code to solve quadratic equations. Formulario 3 contains code to perform basic math operations or factorials and exponents on two input values. Formulario 4 contains code to analyze a sentence for palindromic words, numbers/words, or convert Roman numerals to Arabic numbers.

Uploaded by

Denise
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/ 12

Formulario 1:

Public Class Form1


Private Sub BntGenerar_Click(sender As Object, e As EventArgs) Handles
BntGenerar.Click
Dim numero, NC, i As Integer
i = 0
Dim guardar As String
Dim asterisco, asteriscoG As String
asterisco = "*"
asteriscoG = ""
guardar = ""
numero = txtNumero.Text
NC = txtNumero.Text

Do
guardar = numero.ToString + " " + guardar
numero = numero - 1

txtSerie.Text = txtSerie.Text + vbCrLf + guardar

Loop Until (numero = 0)

Do
asteriscoG = asteriscoG + " " + asterisco
txtAsterisco.Text = txtAsterisco.Text + vbCrLf + asteriscoG

i = i + 1
Loop Until (i = NC)
End Sub

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


BtnLimpiar.Click
txtNumero.Clear()
txtSerie.Clear()
txtAsterisco.Clear()

End Sub
End Class
Formulario 2:
Public Class Form2
Private Sub BntResolver_Click(sender As Object, e As EventArgs) Handles
BntResolver.Click

Dim res, x1, x2, Xima As Double

res = ((txtB.Text * txtB.Text) - (4 * txtA.Text * txtC.Text))


If (res < 0) Then
x1 = ((-txtB.Text) / (2 * txtA.Text))
x1 = (x1 / (2 * txtA.Text))
res = (-res)
Xima = ((Math.Sqrt(res)) / (2 * txtA.Text))
x1 = Math.Round(x1, 2)
Xima = Math.Round(Xima, 2)

txtX1.Text = x1.ToString + " + " + Xima.ToString + "i"


txtX2.Text = x1.ToString + " - " + Xima.ToString + "i"

Else
x1 = (-txtB.Text) + (Math.Sqrt(res))
x1 = x1 / (2 * txtA.Text)

x2 = (-txtB.Text) - (Math.Sqrt(res))
x2 = x2 / (2 * txtA.Text)

txtX1.Text = x1
txtX2.Text = x2
End If

End Sub
Private Sub BtnLimpiar_Click(sender As Object, e As EventArgs) Handles
BtnLimpiar.Click
txtA.Clear()
txtB.Clear()
txtC.Clear()
txtX1.Clear()
txtX2.Clear()

End Sub

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


txtX1.Enabled = False
txtX2.Enabled = False
End Sub
End Class

Formulario 3:
Public Class Form3
Private Sub BtnResolver_Click(sender As Object, e As EventArgs) Handles
BtnResolver.Click
Dim v1, fact1, pot1 As Double
Dim v2, fact2, pot2 As Double
Dim resultado As Double
fact1 = 1
fact2 = 1
v1 = 0.0
v2 = 0.0
resultado = 0.0
v1 = txtValor1.Text
v2 = txtValor2.Text
If (RbtnSuma.Checked = True) Then

resultado = v1 + v2
txtRespuesta.Text = (txtValor1.Text + " + " + txtValor2.Text + " = " +
resultado.ToString)

ElseIf (RbtnResta.Checked = True) Then

resultado = v1 - v2
txtRespuesta.Text = (txtValor1.Text + " - " + txtValor2.Text + " = " +
resultado.ToString)

ElseIf (RbtnDivision.Checked = True) Then

resultado = v1 / v2
txtRespuesta.Text = (txtValor1.Text + " / " + txtValor2.Text + " = " +
resultado.ToString)

ElseIf (RbtnFactorial.Checked = True) Then

For n = 1 To v1
fact1 = fact1 * n

Next n

For n = 1 To v2
fact2 = fact2 * n

Next n
If (fact1 > fact2) Then
txtRespuesta.Text = ("El factorial de " + v1.ToString + " que es: "
+ fact1.ToString + " es mayor que el factorial de " + v2.ToString + " que es: " +
fact2.ToString)
ElseIf (fact2 > fact1) Then
txtRespuesta.Text = ("El factorial de " + v2.ToString + " que es: "
+ fact2.ToString + " es mayor que el factorial de " + v1.ToString + " que es: " +
fact1.ToString)

End If

ElseIf (RbtnPotencia.Checked = True) Then


txtPotenciaV1.Enabled = False
txtPotenciaV2.Enabled = False
pot1 = v1 ^ txtPotenciaV1.Text
pot2 = v2 ^ txtPotenciaV2.Text
txtRespuesta.Text = ("La potencia de " + v1.ToString + "a la" +
txtPotenciaV1.Text + " es: " + pot1.ToString)
txtRespuesta.Text = txtRespuesta.Text + vbCrLf + ("La potencia de " +
v2.ToString + "a la" + txtPotenciaV2.Text + " es: " + pot2.ToString)
End If
End Sub

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


BtnLimpiar.Click
txtValor1.Clear()
txtValor2.Clear()
txtRespuesta.Clear()
txtPotenciaV1.Clear()
txtPotenciaV2.Clear()
End Sub

End Class

Formulario 3:
Public Class Form3
Private Sub BtnResolver_Click(sender As Object, e As EventArgs) Handles
BtnResolver.Click
Dim v1, fact1, pot1 As Double
Dim v2, fact2, pot2 As Double
Dim resultado As Double
fact1 = 1
fact2 = 1
v1 = 0.0
v2 = 0.0
resultado = 0.0
v1 = txtValor1.Text
v2 = txtValor2.Text

If (RbtnSuma.Checked = True) Then

resultado = v1 + v2
txtRespuesta.Text = (txtValor1.Text + " + " + txtValor2.Text + " = " +
resultado.ToString)

ElseIf (RbtnResta.Checked = True) Then

resultado = v1 - v2
txtRespuesta.Text = (txtValor1.Text + " - " + txtValor2.Text + " = " +
resultado.ToString)

ElseIf (RbtnDivision.Checked = True) Then

resultado = v1 / v2
txtRespuesta.Text = (txtValor1.Text + " / " + txtValor2.Text + " = " +
resultado.ToString)

ElseIf (RbtnFactorial.Checked = True) Then

For n = 1 To v1
fact1 = fact1 * n

Next n

For n = 1 To v2
fact2 = fact2 * n

Next n
If (fact1 > fact2) Then
txtRespuesta.Text = ("El factorial de " + v1.ToString + " que es: "
+ fact1.ToString + " ,es mayor que el factorial de " + v2.ToString + " que es: " +
fact2.ToString)
ElseIf (fact2 > fact1) Then
txtRespuesta.Text = ("El factorial de " + v2.ToString + " que es: "
+ fact2.ToString + " ,es mayor que el factorial de " + v1.ToString + " que es: " +
fact1.ToString)

End If

ElseIf (RbtnPotencia.Checked = True) Then


txtPotenciaV1.Enabled = False
txtPotenciaV2.Enabled = False
pot1 = v1 ^ txtPotenciaV1.Text
pot2 = v2 ^ txtPotenciaV2.Text
txtRespuesta.Text = ("La potencia de " + v1.ToString + "a la" +
txtPotenciaV1.Text + " es: " + pot1.ToString)
txtRespuesta.Text = txtRespuesta.Text + vbCrLf + ("La potencia de " +
v2.ToString + " a la" + txtPotenciaV2.Text + " es: " + pot2.ToString)
End If
End Sub

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


BtnLimpiar.Click
txtValor1.Clear()
txtValor2.Clear()
txtRespuesta.Clear()
txtPotenciaV1.Clear()
txtPotenciaV2.Clear()
End Sub

End Class
Formulario 4:
Public Class Form4
Private Sub BtnGenerar_Click(sender As Object, e As EventArgs) Handles
BtnGenerar.Click

If (RbtnPalindromo.Checked = True) Then


Dim reversa As String
Dim delimitador() As Char
delimitador = {",", " "}
Dim partes() As String = (txtOracion.Text).Split(delimitador)
Dim i, cantidad As Integer
i = 0
Do
reversa = StrReverse(partes(i))
If ((Char.IsLetter(partes(i)))) Then
If (reversa.ToLower = partes(i).ToLower) Then
txtResultado.Text = (txtResultado.Text + vbCrLf + partes(i)
+ " es palindromo")
cantidad = cantidad + 1
End If
End If
i = i + 1
Loop While i < partes.Length
txtResultado.Text = txtResultado.Text + vbCrLf + ("En la oración '" +
txtOracion.Text + "' hay un total de: " + cantidad.ToString + " palabras
palindromas.")

ElseIf (RbtnLetyNum.Checked = True) Then


Dim delimitador() As Char
delimitador = {",", " ", "."}
Dim partes() As String = (txtOracion.Text).Split(delimitador)
Dim i, cantN, cantP As Integer
Dim num, palabra As String
num = ""
palabra = ""
i = 0
Do

If (Char.IsDigit(partes(i))) Then
num = num + " " + partes(i)
cantN = cantN + 1
ElseIf (Char.IsLetter(partes(i))) Then
palabra = palabra + " " + partes(i)
cantP = cantP + 1
End If
i = i + 1
Loop While i < partes.Length

txtResultado.Text = ("Hay " + cantN.ToString + " números en la oración y


son:" + num)
txtResultado.Text = (txtResultado.Text + vbCrLf + " Hay " +
cantP.ToString + " palabras en la oración y son: " + palabra)

ElseIf (RbtnRomano.Checked = True) Then


Dim delimitador() As Char
delimitador = {",", " ", "."}
Dim partes() As String = (txtOracion.Text).Split(delimitador)
Dim i, arabigo, valor As Integer

arabigo = 0

Do
If (Char.IsUpper(partes(i))) Then
For Each letter As String In partes(i)
If letter = "I" Then
valor = 1
ElseIf letter = "V" Then
valor = 5
ElseIf letter = "X" Then
valor = 10
ElseIf letter = "L" Then
valor = 50
ElseIf letter = "C" Then
valor = 100
ElseIf letter = "D" Then
valor = 500
ElseIf letter = "M" Then
valor = 1000
End If

arabigo = arabigo + valor

Next

End If
i = i + 1
Loop While i < partes.Length
txtResultado.Text = ("El número romano de la oración '" +
txtOracion.Text + "' en número arábigo es: " + arabigo.ToString)

End If
End Sub

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


txtResultado.Enabled = False

End Sub

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


BtnLimpiar.Click
txtOracion.Clear()
txtResultado.Clear()

End Sub
End Class
Formulario 5:
Public Class Form5

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


BtnEjecutar.Click
Dim cpDecimal, modulo As Integer
Dim Binario As String
Binario = ""

cpDecimal = TxtDec.Text
While (cpDecimal <> 0)
modulo = cpDecimal Mod 2
cpDecimal = Math.Truncate(cpDecimal / 2)
Binario = modulo.ToString + Binario

End While

TxtBin.Text = Binario
End Sub
End Class

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy