| | |
newbie question
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
Well i need to make a program which would display a certain string in a triangle form in the middle of the console something like this:
it wont display right here but i think you get the point.
I am somewhat able to do that but i need to slow the display so that it looks like it is a triangle and want to be able to run it for as long as possible as this program is just for show...
it works for like a sec and there is text but it is so fast you cant read the text and then i get a error after that.
error:
The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was 3420.
C# Syntax (Toggle Plain Text)
t eee sssss ttttttt
I am somewhat able to do that but i need to slow the display so that it looks like it is a triangle and want to be able to run it for as long as possible as this program is just for show...
C# Syntax (Toggle Plain Text)
using System; class test { //Creating global variables protected static int orix; protected static int oriy; //Function to print string in diffrent areas protected static void echo(string s, int x, int y) { try { Console.SetCursorPosition(orix+x, oriy+y); Console.Write(s); } catch(ArgumentOutOfRangeException error) { Console.Clear(); Console.WriteLine(error.Message); } } //MAIN PROGRAM static void Main() { string str = Console.ReadLine(); int strlength = str.Length;//variable that keep string length int width = Console.WindowWidth, height = Console.WindowHeight; //check to see if string is exist if(strlength != 0) { Console.Clear(); orix = Console.CursorTop; oriy = Console.CursorLeft; //check to see if the console width is 80 or set it if(width != 80) { Console.SetWindowSize(80, height); } int y = 0; while(true) { int hw = Console.WindowWidth/2; int halfway = hw; int ht = hw - strlength; int inc = 2; int incy = 0; int s = 1; for(int i=0;i<strlength;i++) { if(i == strlength-1) { inc = -2; } string stri = ""; for(int n=0;n<s;n++) { stri += str[i]; } s += inc; echo(stri,halfway,y); y++; if(i == 0) { incy = -1; } if(halfway == ht) { incy = 1; } halfway = halfway+incy; } Console.WriteLine(strlength-1); } } else { System.Console.WriteLine("A string needs to be entered for this program to work"); System.Console.ReadKey(); } } }
it works for like a sec and there is text but it is so fast you cant read the text and then i get a error after that.
error:
The value must be greater than or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was 3420.
Last edited by ashneet; Sep 9th, 2006 at 4:21 pm.
![]() |
Similar Threads
- Newbie Question - How to generate a link (PHP)
- Redirecting - Newbie Question (PHP)
- Basic scripting question (Getting Started and Choosing a Distro)
- HttpContext.Current Question (VB.NET)
- newbie... Java load large picture :) Lit'l help plez (Java)
- Newbie Question - Hiding php extension (PHP)
- Stupid Newbie Question (C)
- AGP Aperture Size Question (Windows NT / 2000 / XP)
- How to network two Win98 machines (Networking Hardware Configuration)
Other Threads in the C# Forum
- Previous Thread: New in Asp.net & C#.net 2005
- Next Thread: Object reference not set to an instance of an object.
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart basic bitmap box broadcast buttons c# check checkbox client color combobox contorl control conversion csharp custom database datagrid datagridview dataset datetime degrees deployment development disabled displayingopenforms draganddrop drawing editing editor encryption enum event excel file form format forms function gdi+ httpwebrequest i18n image imageprocessing index input install java label list listbox mandelbrot math mathematics mouseclick mysql operator oracle path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox rows serialization server setup sleep socket sql statistics stream string table text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf xml






