VB.NET

Moderators: seancampbell
Number of threads: 4022
Number of posts: 10035

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Keeping it straight Posted by mreman on 4 May 2004 at 8:51 AM
Hey everyone,
OK, I am a newb. I have been trying to complete a program for class and havent been able to keep some things straight in the console.

I input
Console.WriteLine(" |{0}|{1}|{2}|{3}|{4}|", gameBoard(0, 0), gameBoard(0, 1), gameBoard(0, 2), gameBoard(0, 3), gameBoard(0, 4))

Console.WriteLine(" |{0}|{1}|{2}|{3}|{4}|", gameBoard(1, 0), gameBoard(1, 1), gameBoard(1, 2), gameBoard(1, 3), gameBoard(1, 4))

Console.WriteLine(" |{0}|{1}|{2}|{3}|{4}|", gameBoard(2, 0), gameBoard(2, 1), gameBoard(2, 2), gameBoard(2, 3), gameBoard(2, 4))

Console.WriteLine(" |{0}|{1}|{2}|{3}|{4}|", gameBoard(3, 0), gameBoard(3, 1), gameBoard(3, 2), gameBoard(3, 3), gameBoard(3, 4))

Console.WriteLine(" |{0}|{1}|{2}|{3}|{4}|", gameBoard(4, 0), gameBoard(4, 1), gameBoard(4, 2), gameBoard(4, 3), gameBoard(4, 4))

Which writes my array to the console .. in this program the user can input a number between 1 and 25 into any area in the array . If it is a single digit number the array table stays alligned in the console. If someone inputs a double digit into the array it throws the look off and it is nolonger a square. Is there any way that I can keep the board straight?
Report
Re: Keeping it straight Posted by Baldusarius on 4 May 2004 at 11:35 AM
Use PadLeft and/or PadRight:

GameBoard(0, 0).PadLeft(2, ' ')
Report
Re: Keeping it straight Posted by mreman on 4 May 2004 at 1:03 PM
GREAT! THANKS!..




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.