PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Console class, if anyone wants it-VBForums
Results 1 to 27 of 27

Thread: Console class, if anyone wants it

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    Console class, if anyone wants it

    I couldn't find a compelete console class for VB, and most of the good ones are in C#. So I just converted some code to vb.net to add it to my library. It's mainly from a project called ExtendedConsole which is written in C#. But I made some changed.... and I think I combined some other programs from C# and VB6 to make this
    Also see the next post for the rest of the code

    VB Code:
    1. ' Please do not remove :)
    2. ' Written by Kourosh Derakshan
    3. '
    4. Option Strict On
    5. Imports System.Runtime.InteropServices
    6. Imports System.Text
    7.  
    8. Public NotInheritable Class ConsoleEx
    9. #Region " Declarations "
    10.         Private hConsoleIn, hConsoleOut As IntPtr
    11.         Private conInfo As Win32Native.CONSOLE_INFO
    12.         Private cursorInfo As Win32Native.CURSOR_INFO
    13.         Private backColor As Integer
    14.         Private backgroundAttrib As Short
    15.  
    16.  
    17.         Enum InputMode
    18.             LineInput
    19.             EchoInput
    20.         End Enum
    21.  
    22.         Public Enum ConsoleColor
    23.             Black = 0
    24.             Blue = Win32Native.FOREGROUND_BLUE
    25.             Green = Win32Native.FOREGROUND_GREEN
    26.  
    27.             SkyBlue = Win32Native.FOREGROUND_BLUE + Win32Native.FOREGROUND_GREEN
    28.  
    29.             Red = Win32Native.FOREGROUND_RED
    30.             Purple = Win32Native.FOREGROUND_BLUE + Win32Native.FOREGROUND_RED
    31.             Brown = Win32Native.FOREGROUND_GREEN + Win32Native.FOREGROUND_RED
    32.             White = Win32Native.FOREGROUND_BLUE + Win32Native.FOREGROUND_GREEN + _
    33.                     Win32Native.FOREGROUND_RED
    34.             Gray = Win32Native.FOREGROUND_INTENSIFY
    35.             BlueForte = Win32Native.FOREGROUND_BLUE + Win32Native.FOREGROUND_INTENSIFY
    36.             GreenForte = Win32Native.FOREGROUND_GREEN + Win32Native.FOREGROUND_INTENSIFY
    37.             SkyBlueForte = Win32Native.FOREGROUND_BLUE + Win32Native.FOREGROUND_GREEN + _
    38.                            Win32Native.FOREGROUND_INTENSIFY
    39.             RedForte = Win32Native.FOREGROUND_RED + Win32Native.FOREGROUND_INTENSIFY
    40.             PurpleForte = Win32Native.FOREGROUND_BLUE + Win32Native.FOREGROUND_RED + _
    41.             Win32Native.FOREGROUND_INTENSIFY
    42.             Yellow = Win32Native.FOREGROUND_GREEN + Win32Native.FOREGROUND_RED + _
    43.             Win32Native.FOREGROUND_INTENSIFY
    44.             WhiteForte = Win32Native.FOREGROUND_BLUE + Win32Native.FOREGROUND_GREEN + _
    45.                          Win32Native.FOREGROUND_RED + Win32Native.FOREGROUND_INTENSIFY
    46.         End Enum
    47.  
    48.         Public Enum CursorType
    49.             Off
    50.             SingleLine
    51.             Block
    52.         End Enum
    53. #End Region
    54.  
    55.         Public Sub New()
    56.             ' Creates a console if there isn't already one loaded.
    57.             Win32Native.AllocConsole()
    58.  
    59.             ' Set the input handle
    60.             hConsoleIn = Win32Native.GetStdHandle(Win32Native.STD_INPUT_HANDLE)
    61.             ' Set the output handle
    62.             hConsoleOut = Win32Native.GetStdHandle(Win32Native.STD_OUTPUT_HANDLE)
    63.  
    64.  
    65.             ' Fill in the console information to conInfo
    66.             conInfo = New Win32Native.CONSOLE_INFO
    67.             updateConsoleInfo()
    68.  
    69.             ' Fill in the cursor information for this console
    70.             cursorInfo = New Win32Native.CURSOR_INFO
    71.             SetCursorType(CursorType.SingleLine)
    72.  
    73.             ' Set the standard background attribute
    74.             backgroundAttrib = CShort((CShort(ConsoleColor.Black) * &H10 + CShort(ConsoleColor.White)))
    75.         End Sub
    76.  
    77.         Protected Overrides Sub Finalize()
    78.             MyBase.Finalize()
    79.             FreeConsole()
    80.         End Sub
    81.  
    82.         Public Property Title() As String
    83.             Get
    84.                 Dim buffer As New StringBuilder(128)
    85.                 Win32Native.GetConsoleTitle(buffer, 128)
    86.                 Return buffer.ToString
    87.             End Get
    88.  
    89.             Set(ByVal Value As String)
    90.                 Win32Native.SetConsoleTitle(Value)
    91.             End Set
    92.         End Property
    93.  
    94.         Public ReadOnly Property Columns() As Integer
    95.             Get
    96.                 Return conInfo.MaxSize.x
    97.             End Get
    98.         End Property
    99.  
    100.         Public ReadOnly Property Rows() As Integer
    101.             Get
    102.                 Return conInfo.MaxSize.y
    103.             End Get
    104.         End Property
    105.  
    106.         ' X position of the cursor (or the carret) on the screen
    107.         Public ReadOnly Property CursorX() As Integer
    108.             Get
    109.                 updateConsoleInfo()
    110.                 Return conInfo.CursorPosition.x
    111.             End Get
    112.         End Property
    113.  
    114.         ' Y position of the cursor (or the carret) on the screen
    115.         Public ReadOnly Property CursorY() As Integer
    116.             Get
    117.                 updateConsoleInfo()
    118.                 Return conInfo.CursorPosition.y
    119.             End Get
    120.         End Property
    121.  
    122.         ' LineInput will let the console read a line at a time. EchoInput lets the console
    123.         ' read each key stroke, as the user types something (You have to use Console.Read ()
    124.         ' instead of Console.ReadLine() when in EchoInput.)
    125.         Public Sub SetMode(ByVal mode As InputMode)
    126.             Dim conMode As Integer
    127.             Win32Native.GetConsoleMode(hConsoleIn, conMode)
    128.  
    129.             If mode = InputMode.EchoInput Then
    130.                 conMode = conMode And Not (Win32Native.ENABLE_LINE_INPUT Or Win32Native.ENABLE_ECHO_INPUT)
    131.             Else
    132.                 conMode = conMode Or (Win32Native.ENABLE_LINE_INPUT Or Win32Native.ENABLE_ECHO_INPUT)
    133.             End If
    134.             Win32Native.SetConsoleMode(hConsoleIn, conMode)
    135.         End Sub
    136.  
    137.         Public Sub Clear()
    138.             Dim written As Integer = 0
    139.             Dim startCoord As New Win32Native.COORD
    140.             startCoord.x = 0 : startCoord.y = 0
    141.  
    142.             Win32Native.FillConsoleOutputCharacter(hConsoleOut, " "c, conInfo.MaxSize.x * conInfo.MaxSize.y, startCoord, written)
    143.             Win32Native.FillConsoleOutputAttribute(hConsoleOut, backgroundAttrib, conInfo.MaxSize.x * conInfo.MaxSize.y, startCoord, written)
    144.  
    145.             MoveCursor(1, 1)
    146.         End Sub
    147.  
    148.         ' Use only if the console is in LineInput mode. If value is true, then the things
    149.         ' that the user types will automatically show up in the console. (In EchoInput mode
    150.         ' nothing shows up automatically)
    151.         Public Sub EchoInput(ByVal value As Boolean)
    152.             Dim Ret As Integer
    153.             Win32Native.GetConsoleMode(hConsoleIn, Ret)
    154.             If value Then
    155.                 Ret = Ret Or (Win32Native.ENABLE_ECHO_INPUT)
    156.             Else
    157.                 Ret = Ret And Not (Win32Native.ENABLE_ECHO_INPUT)
    158.             End If
    159.             Win32Native.SetConsoleMode(hConsoleIn, Ret)
    160.         End Sub
    161.  
    162.         Public Sub SetColor(ByVal foreColor As ConsoleColor, ByVal backColor As ConsoleColor)
    163.             Me.backColor = CInt(backColor)
    164.             SetColor(foreColor)
    165.         End Sub
    166.  
    167.         Public Sub SetColor(ByVal foreColor As ConsoleColor)
    168.             Win32Native.SetConsoleTextAttribute(hConsoleOut, CInt(foreColor) + 16 * backColor)
    169.         End Sub
    170.  
    171.         Public Sub SetClsColor(ByVal backColor As ConsoleColor)
    172.                backgroundAttrib = CShort(backColor) * &H10S
    173.         End Sub
    174.  
    175.         Public Sub MoveCursor(ByVal x As Integer, ByVal y As Integer)
    176.             conInfo.CursorPosition.x = CShort(x - 1)
    177.             conInfo.CursorPosition.y = CShort(y - 1)
    178.             If cursorInfo.Visible Then
    179.                 Dim coord As Integer = conInfo.CursorPosition.x + conInfo.CursorPosition.y * &H10000
    180.                 Win32Native.SetConsoleCursorPosition(hConsoleOut, coord)
    181.             End If
    182.         End Sub
    183.  
    184.  
    185.         ' Change the cursor's shape and visibility state.
    186.         Public Sub SetCursorType(ByVal newType As CursorType)
    187.             '  Change the cursor type.
    188.             Select Case newType
    189.                 Case CursorType.Block
    190.                     cursorInfo.Size = 100
    191.                     cursorInfo.Visible = True
    192.  
    193.                 Case CursorType.SingleLine
    194.                     cursorInfo.Size = 10
    195.                     cursorInfo.Visible = True
    196.  
    197.                 Case CursorType.Off
    198.                     cursorInfo.Size = 100
    199.                     cursorInfo.Visible = False
    200.             End Select
    201.  
    202.             Win32Native.SetConsoleCursorInfo(hConsoleOut, cursorInfo)
    203.  
    204.             ' Move the cursor to its correct position.
    205.             MoveCursor(conInfo.CursorPosition.x, conInfo.CursorPosition.y)
    206.         End Sub
    207.  
    208.         ' Forces to close the console. Don't call if not necessary.
    209.         Public Sub FreeConsole()
    210.             ' I just added these myself. I don't if I really have to do this, but I thought
    211.             ' they are necessary. That's why it's in a Try-Catch block, because I don't
    212.             ' know if it may cause an error or not. But it shouldn't.
    213.             Try
    214.                 Win32Native.FreeConsole()
    215.                 Win32Native.CloseHandle(hConsoleIn)
    216.                 Win32Native.CloseHandle(hConsoleOut)
    217.                 Win32Native.FreeConsole()
    218.             Catch
    219.             End Try
    220.         End Sub
    221.  
    222.  
    223.         Private Sub updateConsoleInfo()
    224.             ' Fill in the console information to conInfo
    225.             Win32Native.GetConsoleScreenBufferInfo(hConsoleOut, conInfo)
    226.         End Sub
    227.     End Class
    Last edited by MrPolite; Jun 5th, 2005 at 04:43 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    and this class is used by the above class:
    VB Code:
    1. ' Please do not remove :)
    2. ' Written by Kourosh Derakshan
    3. '
    4.   Friend Class Win32Native
    5.         ' Input and output handle
    6.         Friend Const STD_OUTPUT_HANDLE As Integer = -11&
    7.         Friend Const STD_INPUT_HANDLE As Integer = -10&
    8.         ' Echo Input would let the program to receive each key stroke.
    9.         Friend Const ENABLE_LINE_INPUT As Short = &H2S
    10.         Friend Const ENABLE_ECHO_INPUT As Short = &H4S
    11.  
    12.         ' Color codes
    13.         Friend Const FOREGROUND_BLUE As Integer = &H1&
    14.         Friend Const FOREGROUND_GREEN As Integer = &H2&
    15.         Friend Const FOREGROUND_RED As Integer = &H4&
    16.         Friend Const FOREGROUND_INTENSIFY As Integer = &H8&
    17.         Friend Const BACKGROUND_BLUE As Integer = &H10&
    18.         Friend Const BACKGROUND_GREEN As Integer = &H20&
    19.         Friend Const BACKGROUND_INTENSIFY As Integer = &H80&
    20.  
    21.  
    22.  
    23.         Public Enum BACKGROUNDCOLOR
    24.             bBLUE = &H10&   'BACKGROUND_BLUE
    25.             bGREEN = &H20&  'BACKGROUND_GREEN
    26.             bRED = &H40&    'BACKGROUND_RED
    27.             bBRIGHT = &H80& 'BACKGROUND_INTENSITY
    28.         End Enum
    29.  
    30.         <StructLayout(LayoutKind.Sequential)> _
    31.         Friend Structure COORD
    32.             Friend x, y As Short
    33.         End Structure
    34.  
    35.         <StructLayout(LayoutKind.Sequential)> _
    36.         Friend Structure RECT
    37.             Dim Left, Top, Right, Bottom As Short
    38.         End Structure
    39.  
    40.         <StructLayout(LayoutKind.Sequential)> _
    41.         Friend Structure CONSOLE_INFO
    42.             Friend Size As COORD
    43.             Friend CursorPosition As COORD
    44.             Friend Attribute As Short
    45.             Friend Window As RECT
    46.             Friend MaxSize As COORD
    47.         End Structure
    48.  
    49.         <StructLayout(LayoutKind.Sequential)> _
    50.         Friend Structure CURSOR_INFO
    51.             Friend Size As Integer
    52.             Friend Visible As Boolean
    53.         End Structure
    54.  
    55.  
    56.  
    57.  
    58.  
    59.         <DllImport("kernel32")> _
    60.                Public Shared Sub SetConsoleTitle(ByVal lpTitleStr As String)
    61.         End Sub
    62.  
    63.         <DllImport("kernel32")> _
    64.         Public Shared Sub GetConsoleTitle(ByVal lpBuff As StringBuilder, ByVal buffSize As Integer)
    65.         End Sub
    66.  
    67.         <DllImport("kernel32")> _
    68.                Public Shared Function SetConsoleTextAttribute(ByVal hConsoleOutput As IntPtr, ByVal wAttributes As Integer) As Integer
    69.         End Function
    70.  
    71.         <DllImport("kernel32")> _
    72.         Public Shared Function FillConsoleOutputCharacter(ByVal Handle As IntPtr, ByVal uChar As Char, _
    73.                                                           ByVal Len As Integer, ByVal start As COORD, ByRef written As Integer) As Integer
    74.         End Function
    75.  
    76.         <DllImport("kernel32")> _
    77.         Public Shared Function FillConsoleOutputAttribute(ByVal Handle As IntPtr, ByVal att As Short, _
    78.                                                           ByVal Len As Integer, ByVal start As COORD, _
    79.                                                           ByRef writted As Integer) As Boolean
    80.         End Function
    81.  
    82.  
    83.         <DllImport("kernel32")> _
    84.         Public Shared Sub GetConsoleScreenBufferInfo(ByVal Handle As IntPtr, _
    85.                                                      ByRef info As CONSOLE_INFO)
    86.         End Sub
    87.  
    88.         <DllImport("kernel32")> _
    89.         Public Shared Function SetConsoleCursorInfo(ByVal Handle As IntPtr, ByRef info As CURSOR_INFO) As Boolean
    90.         End Function
    91.  
    92.         <DllImport("kernel32")> _
    93.         Public Shared Function SetConsoleCursorPosition(ByVal handle As IntPtr, ByVal coord As Integer) As Boolean
    94.         End Function
    95.  
    96.         <DllImport("kernel32")> _
    97.         Public Shared Function GetStdHandle(ByVal nStdHandle As Integer) As IntPtr
    98.         End Function
    99.  
    100.         <DllImport("kernel32")> _
    101.         Public Shared Sub GetConsoleMode(ByVal hConsoleHandle As IntPtr, ByRef lpMode As Integer)
    102.         End Sub
    103.  
    104.         <DllImport("kernel32")> _
    105.         Public Shared Sub SetConsoleMode(ByVal hConsoleHandle As IntPtr, ByVal dwMode As Integer)
    106.         End Sub
    107.  
    108.         <DllImport("kernel32")> _
    109.         Public Shared Function CloseHandle(ByVal hObject As IntPtr) As Integer
    110.         End Function
    111.  
    112.         <DllImport("kernel32")> _
    113.         Public Shared Function AllocConsole() As Integer
    114.         End Function
    115.  
    116.         <DllImport("kernel32")> _
    117.         Public Shared Function FreeConsole() As Integer
    118.         End Function
    119.  
    120.     End Class
    Last edited by MrPolite; Jun 5th, 2005 at 04:44 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Btw is there a way to create a console in a windows forms project, using the default System.Console class?
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086
    What benefit would someone gets from this code ??

  5. #5

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Pirate
    What benefit would someone gets from this code ??
    Lets you:
    -change the foreground or background color of the text
    -change the background color of the console (call SetCLSColor, and then the Clear function)
    -Change or read the title of the console
    -clear a console window
    -change the input mode of the console (call SetMode - whether it should read the input line by line, or to read every key stroke one by one)
    -move the cursor to any random position
    -enable/disable showing what the user types in the console ( call EchoInput )
    -get the size of the console window (number of columns and rows)
    -get the current position of the cursor
    -change the cursor type (the carret)
    -close the console whenever you want (FreeConsole() )
    -create a console by calling this class (althought it doesnt let you read/write.... it may not be necessary if someone can answer my previous post in this thread)

    only one of these is enough reason for me to use this class. You don't have to use this instead of the Console class. In a console app, you just define an instance of this class and you can use it as a "tool". I dont know, but if it's necessary I can add the Read/Readline/Write functions to it and make it like a stand-alone console so you wouldn't need the system.console at all. I just need to know if it's possible to create a System.Console window in a windows forms project (and I believe it should be)
    Last edited by MrPolite; May 25th, 2003 at 05:42 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086
    Wow that should be awesome ! maybe I can't help you here , but thanks for sharing !

  7. #7

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    aah forgot a peice.... added a new function. Lets you change the background color of the console as well as the background color of the text.

    VB Code:
    1. Public Sub SetClsColor(ByVal backColor As ConsoleColor)
    2.             backgroundAttrib = CShort(backColor) * &H10S
    3.   End Sub
    You call this and choose a backcolor, and then you call the Clear function. It will change the backcolor of the console.
    What I don't understand is that the C# version of this function received a backcolor AND a forecolor, while the forecolor seems quite useless (since it doesnt affect the text color). So I just removed the forecolor from the function. In case I'm wrong, here's the original function:
    VB Code:
    1. static public void SetClsColor(ConsoleColor back, ConsoleColor fore)
    2.         {
    3.             m_BackAtt = (short)(((short) back) * 0x10 + (short) fore);
    4.         }
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  8. #8
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    Mr Polite -

    Would you be willing to upload a small sample of how to use this code?

    Thanks.

  9. #9
    Lively Member Tygur's Avatar
    Join Date
    Jul 2002
    Posts
    108
    Originally posted by MrPolite
    Btw is there a way to create a console in a windows forms project, using the default System.Console class?
    At first glance, it looks like you can't. It looks like, in a windows forms project, you have to use api calls, even to write to the console, and you probably have to call the AllocConsole API to make a console window for your process first. Maybe I'll test this further later, but that's how it looks.

    Right now, I don't have much time, but I do know how to use the console api functions, if you need help, as I had to write a similar class like this for myself, which actually does far more than this one you posted does..

  10. #10

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by wayneh
    Mr Polite -

    Would you be willing to upload a small sample of how to use this code?

    Thanks.
    sorry I ignored you for a while I made a little sample

    Console Sample
    Last edited by MrPolite; Jun 5th, 2005 at 04:51 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  11. #11

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    and here's the code of it, if you dont wanna download it.... put this in a console project, as sub main. Put the consoleEx class and Win32Native in the project also

    VB Code:
    1. Module Module1
    2.  
    3.  
    4.     Sub Main()
    5.         Dim conEx As New ConsoleEx
    6.  
    7.         Console.WriteLine("Hello world... changing the title")
    8.         conEx.Title = "New Title!"
    9.         Console.WriteLine("The new title is: " & conEx.Title)
    10.         Console.WriteLine()
    11.  
    12.  
    13.  
    14.  
    15.  
    16.  
    17.         Console.WriteLine("Type something. Everything will be shown in upper-case. Press enter to stop:")
    18.         ' Change the input mode to receive every key stroke
    19.         conEx.SetMode(ConsoleEx.InputMode.EchoInput)
    20.         Do
    21.             Dim asciiCode As Integer
    22.             Dim aChar As Char
    23.  
    24.             ' Note that I'm not calling the Readline method, I'm calling the Read method in this mode
    25.             asciiCode = CInt(Console.Read())  ' Returns the ascii code of the entered character
    26.  
    27.             ' 13 is the code for enter
    28.             If asciiCode = 13 Then
    29.                 Exit Do
    30.             End If
    31.  
    32.             ' Convert the asciicode to its character
    33.             aChar = Chr(asciiCode)
    34.             aChar = Char.ToUpper(aChar)
    35.  
    36.             Console.Write(aChar)
    37.         Loop
    38.         Console.WriteLine()
    39.         Console.WriteLine("Press anykey to clear the screen...")
    40.         Console.Read()
    41.  
    42.         ' Change back the input-mode to line input
    43.         conEx.SetMode(ConsoleEx.InputMode.LineInput)
    44.         conEx.Clear()
    45.  
    46.  
    47.  
    48.  
    49.  
    50.  
    51.         conEx.SetCursorType(ConsoleEx.CursorType.Off)
    52.         Console.WriteLine("Cursor turned off ...")
    53.         Console.ReadLine()
    54.         Console.WriteLine()
    55.  
    56.         conEx.SetCursorType(ConsoleEx.CursorType.Block)
    57.         Console.WriteLine("Block-type cursor...")
    58.         Console.ReadLine()
    59.         Console.WriteLine()
    60.  
    61.         Console.WriteLine("Cursor restored...")
    62.         conEx.SetCursorType(ConsoleEx.CursorType.SingleLine)
    63.         Console.ReadLine()
    64.         conEx.Clear()
    65.  
    66.  
    67.  
    68.  
    69.  
    70.  
    71.         Console.WriteLine("Turning off the echo, type something and press enter...")
    72.         conEx.EchoInput(False)
    73.         Dim tmpStr As String = Console.ReadLine()
    74.         Console.WriteLine("You typed: " & tmpStr)
    75.         conEx.EchoInput(True)
    76.  
    77.         conEx.SetMode(ConsoleEx.InputMode.EchoInput)
    78.         Console.WriteLine("Press any key to continue...")
    79.         Console.Read()
    80.         conEx.SetMode(ConsoleEx.InputMode.LineInput)
    81.         conEx.Clear()
    82.  
    83.  
    84.  
    85.  
    86.  
    87.         ' (1 is the smallest position, not 0)
    88.         conEx.MoveCursor(1, 10)
    89.         conEx.SetColor(ConsoleEx.ConsoleColor.Red)
    90.         Console.WriteLine("RED")
    91.         conEx.SetColor(ConsoleEx.ConsoleColor.Blue)
    92.         Console.WriteLine("Type in blue: ")
    93.         Console.ReadLine()
    94.  
    95.         ' Original color
    96.         conEx.SetColor(ConsoleEx.ConsoleColor.White)
    97.  
    98.  
    99.         conEx.SetMode(ConsoleEx.InputMode.EchoInput)
    100.         Console.WriteLine("Press any key to continue...")
    101.         Console.Read()
    102.     End Sub
    103.  
    104. End Module
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  12. #12
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    Thanks for the upload, but I can't get any of it to work!

    I don't use .NET - I use VB6.

  13. #13
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    then you shouldn't be watching this forum
    \m/\m/

  14. #14
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    PT Exorcist:

    1) I wasn't talking to you

    2) I'm pretty sure there's no law against checking out any forum I wish

    3) Were you born a jerk - or have you just grown into one?

  15. #15

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by wayneh
    Thanks for the upload, but I can't get any of it to work!

    I don't use .NET - I use VB6.
    heheh, you cant use it unless someone compiles it in a way to work with vb6, and I don't really know how they do that.... it's quit easy to find something like this written in vb6, I think
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  16. #16
    Hyperactive Member
    Join Date
    May 1999
    Location
    Sunny Southern Weather
    Posts
    406
    Thanks anyway -

    I'll still hang on to the code and see if I can use it.

  17. #17

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by wayneh
    Thanks anyway -

    I'll still hang on to the code and see if I can use it.
    hehe you do VB6 and you're trying to use the code, the people on the VB.NET forum do VB.NET and I don't think anyone has tried to use this yet

    Good luck... Just in case you don't know, convert the integer datatypes to long if you wanna convert it to vb6
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  18. #18
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086
    Originally posted by PT Exorcist
    then you shouldn't be watching this forum
    lol ...


    wayneh , In order to run the project , you need the .NET Framework . It would be quite difficult to convert that to VB6 (since this proj is based on the base Console Class of .NET Framework) .

  19. #19
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Originally posted by wayneh
    PT Exorcist:

    1) I wasn't talking to you

    2) I'm pretty sure there's no law against checking out any forum I wish

    3) Were you born a jerk - or have you just grown into one?
    of course u can watch this forum..but its more than obvious than a vb.net class wouldnt compile in vb6 as it is not totally oop..then asking for a way to use it (in vb.net) wasnt the smartest question to ask

    ok u rule
    \m/\m/

  20. #20
    Lively Member
    Join Date
    Oct 2002
    Posts
    67
    OMG that is so lame, the IDE wont even let me OPEN your project since im on 02 instead of 03.. rediculus

  21. #21
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,086
    Originally posted by Iamthewalrus15
    OMG that is so lame, the IDE wont even let me OPEN your project since im on 02 instead of 03.. rediculus
    Why don't you try the converter under my sig. It converts VS.NET 2003 Proj to VS.NET 2002 !

  22. #22

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Originally posted by Iamthewalrus15
    OMG that is so lame, the IDE wont even let me OPEN your project since im on 02 instead of 03.. rediculus
    you dont really need to CONVERT it back... just start a new solution (console class), remove the main module and add the classes from my project
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  23. #23

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    uuh I'm just trying to upload some files for this post... you can safely ignore this
    Attached Files Attached Files
    Last edited by MrPolite; Jun 5th, 2005 at 04:52 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  24. #24

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    dll file
    Attached Files Attached Files
    Last edited by MrPolite; Jun 5th, 2005 at 04:53 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  25. #25

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    sample project
    Attached Files Attached Files
    Last edited by MrPolite; Jun 5th, 2005 at 04:49 PM.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  26. #26
    New Member
    Join Date
    Jul 2004
    Posts
    1

    Do you have the C# version of the ConsoleEX that you posted?

    I could re-write the C# version but if you have it, please post it

  27. #27
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489
    hey man. that's a pretty neat sample. You obviousely put a lot of effort into this class. Good work man!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width