Well is it possible to recieve the key down event in a console?
right now I'm doing console.readline which requires Enter to be pressed, I want the program to recieve each key as they are being pressed. is it possible to do with a console app?
unzip this dll into your projects folder and add a refernce to it. Here is some sample VB code to use it. BTW the reason I put it into a dll is because the code is C# and there were a couple operators I couldnt figure out the VB equivilant of to transfer the code to VB
Code:
Imports System
Public Module Test
Public Sub Main()
Dim tst As New ConsoleMode()
tst.EnableCharMode()
Dim i As integer
While True
i = Console.Read()
Console.Writeline(Microsoft.VisualBasic.Chr(i))
If i = 120 then Exit While ' If x is hit, then exit
End While
tst.EnableLineMode()
End Sub
End Module
Originally posted by Cander unzip this dll into your projects folder and add a refernce to it. Here is some sample VB code to use it. BTW the reason I put it into a dll is because the code is C# and there were a couple operators I couldnt figure out the VB equivilant of to transfer the code to VB
Code:
Imports System
Public Module Test
Public Sub Main()
Dim tst As New ConsoleMode()
tst.EnableCharMode()
Dim i As integer
While True
i = Console.Read()
Console.Writeline(Microsoft.VisualBasic.Chr(i))
If i = 120 then Exit While ' If x is hit, then exit
End While
tst.EnableLineMode()
End Sub
End Module
You didn't need to compile it. You could have just uploaded the CS file (is that the C# code file extension?). Then we could have added it to our projects. Just because you have a Visual Basic project doesn't mean that all of your code needs to be in Visual Basic. You could have 1 file written in VB, another in C#, and another in C++, and they would all compile together just fine.
Ahh, gotta love .NET!
Anyway, I was busy just now so I couldn't check out the TextStream object. I'll do that right now.
EDIT:
Never mind. Mis-understood your post.
Last edited by Hu Flung Dung; Aug 7th, 2002 at 02:17 PM.
I'm not completely sure what those do. Seems like their bitwise operators (the bitwise operators in VB are AND, OR, XOR, and NOT) from what I see in MSDN, but it doesn't describe their functionality too well.
Anyway, you should really install Visual Studio .NET. Its over 2 GB (pretty large, heh) but its definately worth it. You get MSDN help, intellisense, tons of debugging tools, you can easily design forms, it has a web-page editor built in (for ASP.NET), and a whole bunch of other impressive features.
yeah i think |= might remove values bitwise. It is obviously the opposite of &= but VB .NET supports &= but apparently not |=
I will eventually install VS .NET, I just feel I am learning alot more by doing everything in notepad. Plus I have a new computer coming in for me at work in a couple months, but the one I have here now just wont handle VS .NET to well.
eeeeeh Cander, you have an answer for every question, dont you?
Thanks a lot for your help... I added a reference to the dll file but for some reason it doesnt work. It says that consoleMode isnt defined (Type 'ConsoleMode' is not defined.)
btw MS did a good favor to everyone by adding console apps to VS so you dotn have to mess with APIs. Now why the hell didnt they make it somehow that it would work compeletly?!!!!