Tutoriales de Visual Basic

Como en tutoriales pasados la finalidad es aprender a utilizar los ciclos que ofrece el lenguaje visual basic .net, lo que hace esta aplicación es mostrar en una caja de texto multilínea el tablero de ajedrez, representando las casillas blancas por una B y las negras por una N, además se ingresa una coordenada en donde se ubica un alfil y muestra la trayectoria donde se puede mover el alfil con un *.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim a As Integer = 1
        Dim b As Integer = 1
        Dim c As Integer = 1
        Dim d As Integer
        Dim aux As String

        While a <= 8
            While b <= 8
                d = Math.Abs(textbox1.Text - a)
                If textbox2.Text - d = b Or textbox2.Text + d = b Then
                    aux = "*"
                    If c = 1 Then
                        c = 0
                    Else
                        c = 1
                    End If
                Else
                    If c = 1 Then
                        aux = "B"
                        c = 0
                    Else
                        aux = "N"
                        c = 1
                    End If
                End If
                textbox3.Text = textbox3.Text + aux
                b = b + 1
            End While
            textbox3.Text = textbox3.Text & vbNewLine
            b = 1
            a = a + 1
        End While
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim a As Integer = 1
        Dim b As Integer = 1
        Dim c As Integer = 1
        Dim d As Integer
        Dim aux As String

        For a = 1 To 8
            For b = 1 To 8
                d = Math.Abs(textbox1.Text - a)
                If textbox2.Text - d = b Or textbox2.Text + d = b Then
                    aux = "*"
                    If c = 1 Then
                        c = 0
                    Else
                        c = 1
                    End If
                Else
                    If c = 1 Then
                        aux = "B"
                        c = 0
                    Else
                        aux = "N"
                        c = 1
                    End If
                End If
                textbox3.Text = textbox3.Text + aux
            Next
            textbox3.Text = textbox3.Text & vbNewLine
            b = 1
        Next
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Dim a As Integer = 1
        Dim b As Integer = 1
        Dim c As Integer = 1
        Dim d As Integer
        Dim aux As String

        Do While a <= 8
            Do While b <= 8
                d = Math.Abs(textbox1.Text - a)
                If textbox2.Text - d = b Or textbox2.Text + d = b Then
                    aux = "*"
                    If c = 1 Then
                        c = 0
                    Else
                        c = 1
                    End If
                Else
                    If c = 1 Then
                        aux = "B"
                        c = 0
                    Else
                        aux = "N"
                        c = 1
                    End If
                End If
                textbox3.Text = textbox3.Text + aux
                b = b + 1
            Loop
            textbox3.Text = textbox3.Text & vbNewLine
            b = 1
            a = a + 1
        Loop
    End Sub

Autor: elgame DescargarDescargar

Comentarios en "de ajedrez con for, while en Visual Basic .net"

Table 'programa_programas.t_comentarios' doesn't exist