by Richard Caetano (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating:
(8 Votes)
Visual Basic doesn't have the ability to read or write from the console. To accomplish this, the Win32 API exports a set of functions that interacts with a console window using handles.
clsWinConsole is a simple VB class that encapsulates the code needed to open, write/read, and close a console window. Here is a code snippet that demonstrates how to use clsWinConsole:
Public Sub Main()
Dim console as New clsWinConsole
Dim inp As String
console.Show
console.WriteText "Text"
inp = console.ReadText
console.WriteText inp
console.Hide
End Sub
Side Effects
Tested with Windows 2000 and Windows XP
Download Console API Class (2 KB)