Saturday, 11 October 2014

Print Diamond model from source numbers with VB.Net 2012

Hi All, Herewith I share one sample classic how to prepare diamond that build from some of number and write on VB.Net 2012. normally for this case you only necessary two function that is : for..next and do while.
Let's you know the code.


Design form:
1 form
2. one textbox and set to Multiline

the code is :

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim n, y, a, b As Integer
        
        For n = 1 To 6
            y = 1
            TextBox1.TextAlign = HorizontalAlignment.Center
            Do While y <= n
                TextBox1.Text = TextBox1.Text & " " & y
                y = y + 1
            Loop
            TextBox1.Text = TextBox1.Text & vbCrLf
        Next
        For a = 5 To 1 Step -1
            b = 1
            Do While b <= a
                TextBox1.Text = TextBox1.Text & " " & b
                b = b + 1
            Loop
            TextBox1.Text = TextBox1.Text & vbCrLf
        Next
    End Sub
End Class


run your project and ....


See you again

No comments:

Post a Comment