Module Module1
Sub Print(ByVal str, ByVal n)
For index As Integer = 1 To n
Console.Write(str)
Next
End Sub
Sub PrintLine(ByVal str, ByVal n)
Print(str, n)
Console.WriteLine()
End Sub
Sub Main()
For row As Integer = 1 To 6
For column As Integer = 1 To 6
Console.Write("* ")
Next
Console.WriteLine()
Next
For row As Integer = 1 To 6
PrintLine("* ", row)
Next
For row As Integer = 6 To 1 Step -1
PrintLine("* ", row)
Next
Console.ReadKey()
End Sub
End Module
Tag : .NET, Win (Windows App), Console App, VB.NET, VS 2008 (.NET 3.x), VS 2010 (.NET 4.x)
Module Module1
Sub Main()
For i As Integer = 1 To 6
Console.WriteLine(String.Format("{0, 6}", New String(Enumerable.Repeat(Of Char)("*", i).ToArray())))
Next
Console.WriteLine()
For i As Integer = [..จงเติมคำตอบที่ถูกต้อง..] To [..จงเติมคำตอบที่ถูกต้อง..] Step -1
Console.WriteLine(String.Format("{0, 6}", New String(Enumerable.Repeat(Of Char)("*", i).ToArray())))
Next
Console.WriteLine()
Console.Write("Press any key to continue...")
Console.ReadKey()
End Sub
End Module
Module Module1
Sub Print(ByVal str, ByVal n)
For index As Integer = 1 To n
Console.Write(str)
Next
End Sub
Sub PrintLine(ByVal str, ByVal n)
Print(str, n)
Console.WriteLine()
End Sub
Sub Main()
Console.Write("Input*[1-10]: ")
Dim y As Integer = Console.ReadLine()
If y > 10 Or y < 1 Then
End
End If
Console.Write("Input picture[1-5]: ")
Dim x As Char = Console.ReadLine()
Select x
Case Is = "1"
For row As Integer = 1 To y
For column As Integer = 1 To y
Console.Write("* ")
Next
Console.WriteLine()
Next
Console.ReadKey()
End
Case Is = "2"
For row As Integer = 1 To y
PrintLine("* ", row)
Next
Console.ReadKey()
End
Case Is = "3"
For row As Integer = y To 1 Step -1
PrintLine("* ", row)
Next
Console.ReadKey()
End
Case Is = "4"
Console.ReadKey()
End
Case Is = "5"
Console.ReadKey()
End
End Select
Console.ReadKey()
End Sub
End Module
Module Module1
Sub Print(ByVal str, ByVal n)
For index As Integer = 1 To n
Console.Write(str)
Next
End Sub
Sub PrintLine(ByVal str, ByVal n)
Print(str, n)
Console.WriteLine()
End Sub
Sub Main()
Console.Write("Input*[1-10]: ")
Dim y As Integer = Console.ReadLine()
If y > 10 Or y < 1 Then
End
End If
Console.Write("Input picture[1-5]: ")
Dim x As Char = Console.ReadLine()
Select x
Case Is = "1"
For row As Integer = 1 To y
For column As Integer = 1 To y
Console.Write("* ")
Next
Console.WriteLine()
Next
Console.ReadKey()
End
Case Is = "2"
For row As Integer = 1 To y
PrintLine("* ", row)
Next
Console.ReadKey()
End
Case Is = "3"
For row As Integer = y To 1 Step -1
PrintLine("* ", row)
Next
Console.ReadKey()
End
Case Is = "4"
For i As Integer = 1 To y
Console.WriteLine(String.Format("{0, 11}", New String(Enumerable.Repeat(Of Char)("*", i).ToArray())))
Next
Console.WriteLine()
Console.ReadKey()
End
Case Is = "5"
For i As Integer = y To 1 Step -1
Console.WriteLine(String.Format("{0, 11}", New String(Enumerable.Repeat(Of Char)("*", i).ToArray())))
Next
Console.WriteLine()
Console.ReadKey()
End
End Select
Console.ReadKey()
End Sub
End Module
Module Module1
Sub Main()
Console.Write("Input [1-10]: ")
Dim num As Integer
Dim isNum As Boolean = Integer.TryParse(Console.ReadLine(), num)
Dim format As String = "{0, " & num.ToString() & "}"
Dim message As String = "Press any key to continue..."
Console.WriteLine()
If isNum Then
If num > 0 AndAlso num <= 10 Then
For i As Integer = 1 To num
Console.WriteLine(String.Format(format, New String(Enumerable.Repeat(Of Char)("*", i).ToArray())))
Next
Console.WriteLine()
For i As Integer = num To 1 Step -1
Console.WriteLine(String.Format(format, New String(Enumerable.Repeat(Of Char)("*", i).ToArray())))
Next
Console.WriteLine()
Else
message = "ERROR: Input range must between 1-10."
End If
Else
message = "ERROR: Cann't convert to integer."
End If
Console.Write(message)
Console.ReadKey()
End Sub
End Module
Module Module1
Sub Main()
Console.Write("Input [1-10]: ")
Dim num As Integer
Dim isNum As Boolean = Integer.TryParse(Console.ReadLine(), num)
Dim format As String = "{0, " & num.ToString() & "}"
Dim message As String = "Press any key to continue..."
Console.WriteLine()
If isNum Then
If num > 0 AndAlso num <= 10 Then
For i As Integer = 1 To num
For j As Integer = 1 To num
If j < num - i + 1 Then
Console.Write(" ")
Else
Console.Write("*")
End If
Next
Console.WriteLine()
Next
Console.WriteLine()
For i As Integer = 1 To num
For j As Integer = 1 To num
If j < i Then
Console.Write(" ")
Else
Console.Write("*")
End If
Next
Console.WriteLine()
Next
Console.WriteLine()
Else
message = "ERROR: Input range must between 1-10."
End If
Else
message = "ERROR: Cann't convert to integer."
End If
Console.Write(message)
Console.ReadKey()
End Sub
End Module