473,471 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Console.Clear()

I am writing a small windows applicationa and I am writing console.writeline
data to the console window. But i wanted to clear the area before writing to
the window.

I found the console.clear method, but when I run it it fails with an
uinhandled exception and the exception is that it does not have the handle
to the window.

IM assuming, I need to determine the console windo handle, but Im not sure,
has anyone used this, can point me in the right direction.
Thanks a million
Sep 17 '07 #1
7 10131
On Sep 17, 4:56 am, "Just Me" <news.microsoft.comwrote:
I am writing a small windows applicationa and I am writing console.writeline
data to the console window. But i wanted to clear the area before writing to
the window.

I found the console.clear method, but when I run it it fails with an
uinhandled exception and the exception is that it does not have the handle
to the window.

IM assuming, I need to determine the console windo handle, but Im not sure,
has anyone used this, can point me in the right direction.

Thanks a million
I'm not sure I follow you - I can use Console.Clear with no problems:

////////////////////////
Module Module1

Sub Main()
For i As Integer = 0 To 5
Console.WriteLine("hello world {0}", i.ToString())
Next i

System.Threading.Thread.Sleep(1000)

Console.Clear()

Console.WriteLine("Console Cleared")

Console.Read()
End Sub

End Module
////////////////////////

The above runs with no problems for me - is it throwing an exception
for you? If not please post a small but complete code sample that can
reproduce the error for me.

Thanks,

Seth Rowe

Sep 17 '07 #2
Yes, but you are using a console application. I am viewing the output window
in windows forms application.


"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@k79g2000hse.googlegro ups.com...
On Sep 17, 4:56 am, "Just Me" <news.microsoft.comwrote:
>I am writing a small windows applicationa and I am writing
console.writeline
data to the console window. But i wanted to clear the area before writing
to
the window.

I found the console.clear method, but when I run it it fails with an
uinhandled exception and the exception is that it does not have the
handle
to the window.

IM assuming, I need to determine the console windo handle, but Im not
sure,
has anyone used this, can point me in the right direction.

Thanks a million

I'm not sure I follow you - I can use Console.Clear with no problems:

////////////////////////
Module Module1

Sub Main()
For i As Integer = 0 To 5
Console.WriteLine("hello world {0}", i.ToString())
Next i

System.Threading.Thread.Sleep(1000)

Console.Clear()

Console.WriteLine("Console Cleared")

Console.Read()
End Sub

End Module
////////////////////////

The above runs with no problems for me - is it throwing an exception
for you? If not please post a small but complete code sample that can
reproduce the error for me.

Thanks,

Seth Rowe

Sep 18 '07 #3
On Sep 18, 4:13 am, "Just Me" <news.microsoft.comwrote:
Yes, but you are using a console application. I am viewing the output window
in windows forms application.

"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:11*********************@k79g2000hse.googlegro ups.com...
On Sep 17, 4:56 am, "Just Me" <news.microsoft.comwrote:
I am writing a small windows applicationa and I am writing
console.writeline
data to the console window. But i wanted to clear the area before writing
to
the window.
I found the console.clear method, but when I run it it fails with an
uinhandled exception and the exception is that it does not have the
handle
to the window.
IM assuming, I need to determine the console windo handle, but Im not
sure,
has anyone used this, can point me in the right direction.
Thanks a million
I'm not sure I follow you - I can use Console.Clear with no problems:
////////////////////////
Module Module1
Sub Main()
For i As Integer = 0 To 5
Console.WriteLine("hello world {0}", i.ToString())
Next i
System.Threading.Thread.Sleep(1000)
Console.Clear()
Console.WriteLine("Console Cleared")
Console.Read()
End Sub
End Module
////////////////////////
The above runs with no problems for me - is it throwing an exception
for you? If not please post a small but complete code sample that can
reproduce the error for me.
Thanks,
Seth Rowe
Alright, would you mind posting some code that I can use to replicate
the problem?

Thanks,

Seth Rowe

Sep 18 '07 #4
sure. its a vb.net windows applicaiton with one form.

'//In a button handler

console.clear()
console.writeline("Hello World")
'// Thats it.

Cheers
"rowe_newsgroups" <ro********@yahoo.comwrote in message
news:11*********************@w3g2000hsg.googlegrou ps.com...
On Sep 18, 4:13 am, "Just Me" <news.microsoft.comwrote:
>Yes, but you are using a console application. I am viewing the output
window
in windows forms application.

"rowe_newsgroups" <rowe_em...@yahoo.comwrote in message

news:11*********************@k79g2000hse.googlegr oups.com...
On Sep 17, 4:56 am, "Just Me" <news.microsoft.comwrote:
I am writing a small windows applicationa and I am writing
console.writeline
data to the console window. But i wanted to clear the area before
writing
to
the window.
>I found the console.clear method, but when I run it it fails with an
uinhandled exception and the exception is that it does not have the
handle
to the window.
>IM assuming, I need to determine the console windo handle, but Im not
sure,
has anyone used this, can point me in the right direction.
>Thanks a million
I'm not sure I follow you - I can use Console.Clear with no problems:
////////////////////////
Module Module1
Sub Main()
For i As Integer = 0 To 5
Console.WriteLine("hello world {0}", i.ToString())
Next i
System.Threading.Thread.Sleep(1000)
Console.Clear()
Console.WriteLine("Console Cleared")
Console.Read()
End Sub
End Module
////////////////////////
The above runs with no problems for me - is it throwing an exception
for you? If not please post a small but complete code sample that can
reproduce the error for me.
Thanks,
Seth Rowe

Alright, would you mind posting some code that I can use to replicate
the problem?

Thanks,

Seth Rowe

Sep 18 '07 #5
I allways use console as a diagnostic tool. Its found often in the examples.
Its just that It would be nice to clear the console window, this method was
never available in 1.x of the framework. Dont worry about it, if you dont
know, its not the end of the earth.
What?

One of us is very confused. The Console does not exist in windows
forms, therefore you cannot write to it and you can't clear it. Sure
you can call "Console.WriteLine("Hello World")" but that does nothing
since the console doesn't exist. If you want to have the console you
have to create it like I showed you in my previous code sample.

My question is how do you use the console as a diagnostic tool for
Windows forms when it doesn't exist by default? When you call
Console.WriteLine() where is the text showing up? Are you sure you
aren't talking about Visual Studio's Output window and not the
Console?

Thanks,

Seth Rowe

Sep 18 '07 #6
In a dotNet 2.0 Windows Forms application, you need to explicitly allocate
the console before any of the Console class methods will work. Otherwise,
they throw exceptions.

If you'd like, I'll post my Console helper class, which has an option to
hide the form that calls it.

Mike.

"Just Me" <news.microsoft.comwrote in message
news:uv******************@TK2MSFTNGP02.phx.gbl...
sure. its a vb.net windows applicaiton with one form.

'//In a button handler

console.clear()
console.writeline("Hello World")
'// Thats it.

Cheers


Sep 20 '07 #7
Im interested to see what u did,

Thanks...


"Michael D. Ober" <obermd.@.alum.mit.edu.nospamwrote in message
news:13*************@corp.supernews.com...
In a dotNet 2.0 Windows Forms application, you need to explicitly allocate
the console before any of the Console class methods will work. Otherwise,
they throw exceptions.

If you'd like, I'll post my Console helper class, which has an option to
hide the form that calls it.

Mike.

"Just Me" <news.microsoft.comwrote in message
news:uv******************@TK2MSFTNGP02.phx.gbl...
>sure. its a vb.net windows applicaiton with one form.

'//In a button handler

console.clear()
console.writeline("Hello World")
'// Thats it.

Cheers



Sep 20 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
by: Dave | last post by:
Hi, I have done some research, trying to Clear The Screen in java code. The first option was the obv: system.out.print("\n\n\n\n\n\n\n\n\n\n\n\n"); then i heard about this method:...
3
by: - Steve - | last post by:
Okay I call Console.Read() twice. However when I come up on my second Console.Read() ASCII character 10 is already on the console (that's a line feed). How do I clear out that line feed before...
1
by: Kerry Brown | last post by:
Using Microsoft Visual C# 2005 Express With XP Pro Console.Clear(); used as per the the sample at http://msdn2.microsoft.com/library/209kyy3d(en-us,vs.80).aspx is throwing an exception :...
1
by: cplusplusstudent | last post by:
Hello I am a new C++ programmer and am working with the Visual C++ studio. I am attempting to create a simple console application for myself but I fin that neither of the introductory C++ books...
11
by: sebplays | last post by:
Hi, I seach function for clear screen in VB.Net for console application. Please help me
4
by: djc | last post by:
is this possible: lets say my output has 2 columns with headings like 'host' and 'status'. host status ------------ host1 down host2 up host3 up host4 down
0
by: merco | last post by:
hi, i'm trying to write a console application using vbnet2005. It runs ok in a command prompt. Now, i have to use this console application via telnet (using w2003 server as telnet server) but i...
3
by: Sheikko | last post by:
Sincerly is a little bit complicated to explain to you what I have in my mind, but I will try: Above all the problem is the type of data that I want to passe between these two applications. The...
4
by: Dinsdale | last post by:
I am writing a small console application that runs fine unless I am re- directing the output to a file (i.e. c:\ app.exe >>output.txt) . I have determined that the issue is caused by the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.