You are on page 1of 6

Asignat

ura:
Lenguajes y autmatas I
Docent
e:
Trabajo:

Ing.
Jess
Mquina
de Turing
leo villa
Alumno 15Noviem
s:
Cinthya
breEstefan
Semest2014
re y Nuevo
ISC5BV.
Lugar
Grupo:yCasas
Fecha:
Grande
s,
Chihuah
ua.

Mquina De Turing
Problema

Resultado

Aqui declare las variables que utilizare txts son los nuevos textbox que ponder igualmente
los combs
Public Class Form1
Public txts(0, 0) As TextBox
Public combs(0) As ComboBox
Public conta1 As Integer = 0
Public conta2 As Integer = 1
Public npalabra As String = ""
Aqui haremos que al momento de darle clic al combobox aparezca la cantidad deseada,
tambin hice que se pusierasn los corchetes por eso esta una nueva posicin declarada
Private Sub Cmbox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Cmbox.SelectedIndexChanged
ReDim txts(Cmbox.Text - 1, 3)
ReDim combs(Cmbox.Text - 1)
Dim posy As Integer = 227
Dim posaa As Integer = 225
For i = 0 To Cmbox.Text - 1
txts(i, 0) = New TextBox
txts(i, 0).Location = New Point(78, posy)
txts(i, 0).Size = New Size(25, 20)
txts(i, 0).BackColor = Color.White
Me.Controls.Add(txts(i, 0))
Dim lbl1 As New Label
lbl1.Location = New Point(65, posy)
lbl1.Size = New Size(27, 25)
lbl1.Font = New Font("Arial", 14, FontStyle.Bold)
lbl1.Text = "{"
Me.Controls.Add(lbl1)
Dim lbl5 As New Label
lbl5.Location = New Point(161, posy)
lbl5.Size = New Size(27, 25)
lbl5.Font = New Font("Arial", 14, FontStyle.Bold)
lbl5.Text = "{"
Me.Controls.Add(lbl5)
txts(i, 1) = New TextBox
txts(i, 1).Location = New Point(113, posy)
txts(i, 1).Size = New Size(25, 20)
txts(i, 1).BackColor = Color.White
Me.Controls.Add(txts(i, 1))
txts(i, 2) = New TextBox
txts(i, 2).Location = New Point(188, posy)
txts(i, 2).Size = New Size(25, 20)
txts(i, 2).BackColor = Color.White
Me.Controls.Add(txts(i, 2))
txts(i, 3) = New TextBox
txts(i, 3).Location = New Point(220, posy)
txts(i, 3).Size = New Size(25, 20)

txts(i, 3).BackColor = Color.White


Me.Controls.Add(txts(i, 3))
Dim lbl2 As New Label
lbl2.Location = New Point(250, posy)
lbl2.Size = New Size(27, 25)
lbl2.Font = New Font("Arial", 14, FontStyle.Bold)
lbl2.Text = "}"
Me.Controls.Add(lbl2)
Dim lbl3 As New Label
lbl3.Location = New Point(139, posy)
lbl3.Size = New Size(27, 25)
lbl3.Font = New Font("Arial", 14, FontStyle.Bold)
lbl3.Text = "}"
Me.Controls.Add(lbl3)
Dim lbl4 As New Label
lbl4.Location = New Point(100, posy)
lbl4.Size = New Size(27, 25)
lbl4.Font = New Font("Arial", 10, FontStyle.Bold)
lbl4.Text = ""
Me.Controls.Add(lbl3)
combs(i) = New ComboBox
combs(i).Location = New Point(300, posy)
combs(i).Size = New Size(35, 30)
combs(i).BackColor = Color.White
combs(i).Items.Add("D")
combs(i).Items.Add("I")
Me.Controls.Add(combs(i))
posy += 40
Next
End Sub
en el boton agregar lo que hara sera para agregar mas textbox
Private Sub Btnagregar_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btnagregar.Click
Dim cont As Integer
Dim txt(cont) As TextBox
Dim pos As Integer = 177
txt(cont) = New TextBox
txt(cont).Location = New Point(pos, 41)
txt(cont).Size = New Size(59, 20)
Me.Controls.Add(txt(cont))
cont += 1
pos += 79
End Sub
Private Sub Btnagregar2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Btnagregar2.Click
Dim cont As Integer

Dim txt(cont) As TextBox


Dim pos As Integer = 177
txt(cont) = New TextBox
txt(cont).Location = New Point(pos, 76)
txt(cont).Size = New Size(59, 20)
txt(cont).BackColor = Color.White
txt(cont).BorderStyle = BorderStyle.FixedSingle
Me.Controls.Add(txt(cont))
cont += 1
pos += 79
End Sub
En boton ejecutar lo que hara es que empieze a funcionar nuestra maquina de turing una
vez agregado los datos y lo que hace es mandar a llamar el modulo reglas
Private Sub btnejecutar_Click(sender As System.Object, e As System.EventArgs) Handles
btnejecutar.Click
reglas.checar()
End Sub
En esta parte declare un timer los para que al momento de ejecutarlo se vayan cambiando
los numeros con efecto uno por uno
Private Sub Timer_Tick(sender As System.Object, e As System.EventArgs) Handles
Timer.Tick
Try
txtnum.Select(conta1, conta2)
txtnum.SelectedText = npalabra(conta1)
conta1 += 1
Catch ex As Exception
End Try
End Sub
End Class

Modulo
Aqu es donde se hace los pasos que tiene que hacer declare y llame los txt del form1 para
que tomara lo que se a escrito en ellos
Module reglas
Public Sub checar()
Dim letras() As Char
letras = Form1.txtnum.Text.ToCharArray
Dim texto As String = Form1.txts(0, 0).Text
Dim pos As Char = letras(0)

Use un goto para que siguiera los pasos como dije tambin mande a llamar los txt que
estn en el form1 estas reglas son bsicas para poder elaborar el programa de la mquina
de Turing

1:

For i = 0 To letras.Length - 1
pos = letras(i)
If pos = Form1.txts(0, 1).Text And Form1.txts(0, 0).Text = texto Then
Form1.npalabra = Form1.npalabra & Form1.txts(0, 3).Text
texto = Form1.txts(0, 2).Text
If Form1.combs(0).SelectedItem = "I" Then
GoTo 1
End If

2:

3:

ElseIf pos = Form1.txts(1, 1).Text And Form1.txts(1, 0).Text = texto Then


Form1.npalabra = Form1.npalabra & Form1.txts(1, 3).Text
texto = Form1.txts(1, 2).Text
If Form1.combs(1).SelectedItem = "I" Then
GoTo 2
End If
ElseIf pos = Form1.txts(2, 1).Text And Form1.txts(2, 0).Text = texto Then
Form1.npalabra = Form1.npalabra & Form1.txts(2, 3).Text
texto = Form1.txts(2, 2).Text
If Form1.combs(2).SelectedItem = "I" Then
GoTo 3
End If

4:

5:

ElseIf pos = Form1.txts(3, 1).Text And Form1.txts(3, 0).Text = texto Then


Form1.npalabra = Form1.npalabra & Form1.txts(3, 3).Text
texto = Form1.txts(3, 2).Text
If Form1.combs(3).SelectedItem = "I" Then
GoTo 4
End If
ElseIf pos = Form1.txts(4, 1).Text And Form1.txts(4, 0).Text = texto Then
Form1.npalabra = Form1.npalabra & Form1.txts(4, 3).Text
texto = Form1.txts(4, 2).Text
If Form1.combs(4).SelectedItem = "I" Then
GoTo 5
End If
Exit For
End If
Next
Form1.Timer.Enabled = True

End Sub

You might also like