Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

CConsole - A class for creating console applications
[ All Languages » VB »  Windows]

Total Hit ( 2366)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


Click here to copy the following block
' CCONSOLE Class
'
' Creates a console window and writes to it
' Example:
'   Dim cons As New CConsole
'   cons.WriteString "Hello World"

Private Declare Function AllocConsole Lib "kernel32" () As Long
Private Declare Function FreeConsole Lib "kernel32" () As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As _
  Long
Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) _
  As Long
Private Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" _
  (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal nNumberOfCharsToWrite _
  As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
Const STD_OUTPUT_HANDLE = -11&

' the handle of this console
Dim hConsole As Long

Private Sub Class_Initialize()
  ' allocate a console when this object is created
  If AllocConsole() Then
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE)
  End If
End Sub

Private Sub Class_Terminate()
  ' free the console when this object is destroyed
  If hConsole Then CloseHandle hConsole
  FreeConsole
End Sub

' write a string to the console

Sub WriteString(ByVal Text As String)
  Dim cWritten As Long
  WriteConsole hConsole, ByVal Text, Len(Text), cWritten, ByVal 0&
End Sub


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.