El programa completo me quedo así:
Los pondré por secciones hoy sera el ejemplo de cuadrados medios
1.- Crean una ventana así, donde en los cuadrados medios te piden los periodos y una semilla, utilizaremos 4textbox y 3 botones para generar el procedimiento, limpiarlo y por supuesto salir.
En el botón generar va el siguiente código:
Ojo el text1 es el textbox del numero de peridos, el text2 es la semilla, el text3 es el cuadro de en medio y el text4 es el textbox de abajo.
Public Class ventanaCM
Private Sub Gcm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Gcm.Click
Creamos 5 variables 2 de tipo integer y 3 de tipo double
Dim n_periodo As Integer
Dim tamaño As Integer
Dim cuadrado As Double
Dim nuevo_cuadrado As Double
Dim divisor As Double
n_periodo = text1.Text
For i = 1 To n_periodo
cuadrado = text2.Text ^ 2
text4.Text = cuadrado
tamaño = Len(text4.Text)
If tamaño = 8 Then
nuevo_cuadrado = Mid(text4.Text, 3, 4)
text2.Text = nuevo_cuadrado
End If
If tamaño = 7 Then
text4.Text = "0" & cuadrado
nuevo_cuadrado = Mid(text4.Text, 3, 4)
text2.Text = nuevo_cuadrado
End If
If tamaño = 6 Then
nuevo_cuadrado = Mid(text4.Text, 2, 4)
text2.Text = nuevo_cuadrado
End If
If tamaño = 5 Then
text4.Text = "0" & cuadrado
nuevo_cuadrado = Mid(text4.Text, 2, 4)
text2.Text = nuevo_cuadrado
End If
If tamaño = 4 Then
text4.Text = "00" & cuadrado
nuevo_cuadrado = Mid(text4.Text, 2, 4)
text2.Text = nuevo_cuadrado
End If
divisor = text2.Text / 10000
'If tamaño = 3 Then
'text4.Text = "00000" & cuadrado
'End If
'nuevo_cuadrado = Mid(text4.Text, 3, 4)
'text2.Text = nuevo_cuadrado
text3.Text = text3.Text & vbCrLf & "Periodo [" & i & "] " & text4.Text & " N°centro: " & nuevo_cuadrado & " = " & divisor
If i = n_periodo Then
Label1.Text = "Resultado:"
End If
Next i
End Sub
Este boton es el boton de salir
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Form1.Show()
Me.Hide()
End Sub
Este boton es el de limpiar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
text2.Clear()
text1.Clear()
text3.Clear()
text4.Clear()
End Sub
EXCELENTE APORTE, MIL GRACIAS
ResponderEliminar