Empezaremos creando una ventana similar a esta:
Nescesitaremos tener 5 textbox y 3 botones
En el botón generar tecleamos el siguiente código:
Ojo el text1 es el numero de periodos, el text2 es la semilla1 y semilla es la semilla2, el cuadro de en medio es el text3 y por ultimo el text4 es el de abajo
Public Class ventanaPM
Private Sub Gcm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Gcm.Click
Se crean 5 variables 2 de tipo integer y 3 de tipo double
Dim n_periodo As Integer
Dim tamaño As Integer
Dim multiplicador As Double
Dim nuevo_multi As Double
Dim divisor As Double
n_periodo = text1.Text
For i = 1 To n_periodo
multiplicador = text2.Text * semilla.Text
text4.Text = multiplicador
tamaño = Len(text4.Text)
If tamaño = 8 Then
nuevo_multi = Mid(text4.Text, 3, 4)
text2.Text = semilla.Text
semilla.Text = nuevo_multi
End If
If tamaño = 7 Then
text4.Text = "0" & multiplicador
nuevo_multi = Mid(text4.Text, 3, 4)
text2.Text = semilla.Text
semilla.Text = nuevo_multi
End If
If tamaño = 6 Then
nuevo_multi = Mid(text4.Text, 2, 4)
text2.Text = semilla.Text
semilla.Text = nuevo_multi
End If
If tamaño = 5 Then
text4.Text = "0" & multiplicador
nuevo_multi = Mid(text4.Text, 2, 4)
text2.Text = semilla.Text
semilla.Text = nuevo_multi
End If
If tamaño = 4 Then
text4.Text = "00" & multiplicador
nuevo_multi = Mid(text4.Text, 2, 4)
text2.Text = semilla.Text
semilla.Text = nuevo_multi
End If
divisor = nuevo_multi / 10000
'nuevo_multi = Mid(text4.Text, 3, 4)
'text2.Text = nuevo_multi
text3.Text = text3.Text & vbCrLf & "Periodo [" & i & "] " & text4.Text & " N°centro: " & nuevo_multi & " = " & divisor
If i = n_periodo Then
Label1.Text = "Resultado:"
End If
Next i
End Sub
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
Boton de limpiar
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
text1.Clear()
text2.Clear()
text3.Clear()
text4.Clear()
semilla.Clear()
End Sub
No hay comentarios:
Publicar un comentario