473,804 Members | 3,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Console.Clear()

I am writing a small windows applicationa and I am writing console.writeli ne
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 10355
On Sep 17, 4:56 am, "Just Me" <news.microsoft .comwrote:
I am writing a small windows applicationa and I am writing console.writeli ne
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.WriteLi ne("hello world {0}", i.ToString())
Next i

System.Threadin g.Thread.Sleep( 1000)

Console.Clear()

Console.WriteLi ne("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_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** *************@k 79g2000hse.goog legroups.com...
On Sep 17, 4:56 am, "Just Me" <news.microsoft .comwrote:
>I am writing a small windows applicationa and I am writing
console.writel ine
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.WriteLi ne("hello world {0}", i.ToString())
Next i

System.Threadin g.Thread.Sleep( 1000)

Console.Clear()

Console.WriteLi ne("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_newsgroup s" <rowe_em...@yah oo.comwrote in message

news:11******** *************@k 79g2000hse.goog legroups.com...
On Sep 17, 4:56 am, "Just Me" <news.microsoft .comwrote:
I am writing a small windows applicationa and I am writing
console.writeli ne
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.WriteLi ne("hello world {0}", i.ToString())
Next i
System.Threadin g.Thread.Sleep( 1000)
Console.Clear()
Console.WriteLi ne("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.writeli ne("Hello World")
'// Thats it.

Cheers
"rowe_newsgroup s" <ro********@yah oo.comwrote in message
news:11******** *************@w 3g2000hsg.googl egroups.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_newsgrou ps" <rowe_em...@yah oo.comwrote in message

news:11******* **************@ k79g2000hse.goo glegroups.com.. .
On Sep 17, 4:56 am, "Just Me" <news.microsoft .comwrote:
I am writing a small windows applicationa and I am writing
console.writel ine
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.WriteLi ne("hello world {0}", i.ToString())
Next i
System.Threadin g.Thread.Sleep( 1000)
Console.Clear()
Console.WriteLi ne("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.WriteL ine("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.WriteLi ne() 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******** **********@TK2M SFTNGP02.phx.gb l...
sure. its a vb.net windows applicaiton with one form.

'//In a button handler

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

Cheers


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

Thanks...


"Michael D. Ober" <obermd.@.alum. mit.edu.nospamw rote in message
news:13******** *****@corp.supe rnews.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******** **********@TK2M SFTNGP02.phx.gb l...
>sure. its a vb.net windows applicaiton with one form.

'//In a button handler

console.clear( )
console.writel ine("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
105845
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: System.out.print((char)27 + "[2J");
3
12413
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 I call Console.Read() again?
1
7837
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 : System.IO.IOException was unhandled Message="The handle is invalid.\r\n"
1
2134
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 I own tell me how to clear the console screen or change the font color. Is there some way to do this that could b understood by a novice programmer? Here are the three things I would like to do: Control the size of the console screen when the...
11
4595
by: sebplays | last post by:
Hi, I seach function for clear screen in VB.Net for console application. Please help me
4
1547
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
1188
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 get this error: Unhandled Exception: System.IO.IOException: Handle non valido. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
3
2243
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 complete application that I want to create consiste of two applications: - the console developped with VS C++, that use some libraries developped with Borland C++ - the GUI of application that interact with the console.
4
6272
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 Console.Clear() function. When piping to a file, the console.clear causes the following error: Unhandled Exception: System.IO.IOException: The handle is invalid. at System.IO.IO__Error.WinIOError(Int32 errorCode, String maybeFullPath)
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9150
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5521
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.