Results 1 to 15 of 15

Thread: Matrix Effect

  1. #1

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,828

    Matrix Effect

    I was browsing YouTube today and I came across this video that shows a sort of matrix effect made in a C# console application.

    The link to the code is in the description, so I followed the link, copied and pasted the code it into an online C# to VB converter. I had to make a few changes, but I was able to get it to work in VB just fine and thought to share it with everyone.

    Enjoy!

    VB.NET Code:
    1. Module Module1
    2.     Sub Main()
    3.         Console.Title = "Matrix Effect"
    4.         Console.ForegroundColor = ConsoleColor.DarkGreen
    5.         Console.WindowLeft = InlineAssignHelper(0, 0)
    6.         Console.WindowHeight = InlineAssignHelper(Console.BufferHeight, Console.LargestWindowHeight)
    7.         Console.WindowWidth = InlineAssignHelper(Console.BufferWidth, Console.LargestWindowWidth)
    8.  
    9.         Console.CursorVisible = False
    10.         Dim width As Integer, height As Integer
    11.         Dim y As Integer()
    12.         Dim l As Integer()
    13.         Initialize(width, height, y, l)
    14.         Dim ms As Integer
    15.         While True
    16.             Dim t1 As DateTime = DateTime.Now
    17.             MatrixStep(width, height, y, l)
    18.             ms = 10 - CInt(Math.Truncate(CType(DateTime.Now - t1, TimeSpan).TotalMilliseconds))
    19.             If ms > 0 Then
    20.                 System.Threading.Thread.Sleep(ms)
    21.             End If
    22.             If Console.KeyAvailable Then
    23.                 If Console.ReadKey().Key = ConsoleKey.F5 Then
    24.                     Initialize(width, height, y, l)
    25.                 End If
    26.             End If
    27.         End While
    28.     End Sub
    29.  
    30.     Dim thistime As Boolean = False
    31.  
    32.     Private Sub MatrixStep(ByVal width As Integer, ByVal height As Integer, ByVal y As Integer(), ByVal l As Integer())
    33.         Dim x As Integer
    34.         thistime = Not thistime
    35.         For x = 0 To width - 1
    36.             If x Mod 11 = 10 Then
    37.                 If Not thistime Then
    38.                     Continue For
    39.                 End If
    40.                 Console.ForegroundColor = ConsoleColor.White
    41.             Else
    42.                 Console.ForegroundColor = ConsoleColor.DarkGreen
    43.                 Console.SetCursorPosition(x, inBoxY(y(x) - 2 - ((l(x) \ 40) * 2), height))
    44.                 Console.Write(R)
    45.                 Console.ForegroundColor = ConsoleColor.Green
    46.             End If
    47.             Console.SetCursorPosition(x, y(x))
    48.             Console.Write(R)
    49.             y(x) = inBoxY(y(x) + 1, height)
    50.             Console.SetCursorPosition(x, inBoxY(y(x) - l(x), height))
    51.             Console.Write(" "c)
    52.         Next
    53.     End Sub
    54.  
    55.     Private Sub Initialize(ByRef width As Integer, ByRef height As Integer, ByRef y As Integer(), ByRef l As Integer())
    56.         Dim h1 As Integer
    57.         Dim h2 As Integer = (InlineAssignHelper(h1, (InlineAssignHelper(height, Console.WindowHeight)) \ 2)) \ 2
    58.         width = Console.WindowWidth - 1
    59.         y = New Integer(width - 1) {}
    60.         l = New Integer(width - 1) {}
    61.         Dim x As Integer
    62.         Console.Clear()
    63.         For x = 0 To width - 1
    64.             y(x) = m_r.[Next](height)
    65.             l(x) = m_r.[Next](h2 * (If((x Mod 11 <> 10), 2, 1)), h1 * (If((x Mod 11 <> 10), 2, 1)))
    66.         Next
    67.     End Sub
    68.  
    69.     Dim m_r As New Random()
    70.     Private ReadOnly Property R() As Char
    71.         Get
    72.             Dim t As Integer = m_r.[Next](10)
    73.             If t <= 2 Then
    74.                 Return ChrW(CInt(AscW("0"c)) + m_r.[Next](10))
    75.             ElseIf t <= 4 Then
    76.                 Return ChrW(CInt(AscW("a"c)) + m_r.[Next](27))
    77.             ElseIf t <= 6 Then
    78.                 Return ChrW(CInt(AscW("A"c) + m_r.[Next](27)))
    79.             Else
    80.                 Return ChrW(m_r.[Next](32, 255))
    81.             End If
    82.         End Get
    83.     End Property
    84.  
    85.     Public Function inBoxY(ByVal n As Integer, ByVal height As Integer) As Integer
    86.         n = n Mod height
    87.         If n < 0 Then
    88.             Return n + height
    89.         Else
    90.             Return n
    91.         End If
    92.     End Function
    93.     Private Function InlineAssignHelper(Of T)(ByRef target As T, ByVal value As T) As T
    94.         target = value
    95.         Return value
    96.     End Function
    97.  
    98. End Module

    *Edit:

    I forgot to mention that when the app is opened, it expands completely, but the top left is offset for some reason. Also, resizing the window to make it smaller or clicking the maximize button for the console screws it up.
    Last edited by weirddemon; Mar 27th, 2011 at 12:13 AM.
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: Matrix Effect

    Cool

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Matrix Effect

    I like
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,464

    Re: Matrix Effect

    interesting, but the location is annoying + the way it runs when you maximize the console window is not so good

  5. #5

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,828

    Re: Matrix Effect

    Quote Originally Posted by .paul. View Post
    interesting, but the location is annoying + the way it runs when you maximize the console window is not so good
    Yeah. I tried playing around with it, but I couldn't get it figured out immediately and I didn't want to spend a lot of time playing with it :P
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  6. #6
    New Member norBATman's Avatar
    Join Date
    Aug 2012
    Location
    Philippines
    Posts
    7

    Re: Matrix Effect

    Very like! I tried it on VB! It's cool!

  7. #7
    PowerPoster i00's Avatar
    Join Date
    Mar 2002
    Location
    1/2 way accross the galaxy.. and then some
    Posts
    2,388

    Re: Matrix Effect

    you should probably post the link to the original one that you converted if you're going to use other peoples work

    Great find btw...

    Kris

  8. #8

    Thread Starter
    Wait... what? weirddemon's Avatar
    Join Date
    Jan 2009
    Location
    USA
    Posts
    3,828

    Re: Matrix Effect

    Quote Originally Posted by i00 View Post
    you should probably post the link to the original one that you converted if you're going to use other peoples work

    Great find btw...

    Kris
    Read the original post again. There's a link to the YouTube page. You'll notice that the last time I edited that post, was May of last year =/
    CodeBank contributions: Process Manager, Temp File Cleaner

    Quote Originally Posted by SJWhiteley
    "game trainer" is the same as calling the act of robbing a bank "wealth redistribution"....

  9. #9
    Member
    Join Date
    Mar 2015
    Posts
    51

    Re: Matrix Effect

    How do you get this to work? Where do you paste the code?
    could you try uploading a zip file of it so that, I or other people can understand how it works?

    Thanks,
    Jonathan

  10. #10
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Matrix Effect

    If you have a Visual Basic .Net Development environment, simply choose to create a new project, and select Console Application.
    You should see the template code generated (Module1 and Sub Main), as is in the first post.
    Paste the code from the first post in place of the template code.
    It says it is a console application on the first line of the first post.

  11. #11
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: Matrix Effect

    Quote Originally Posted by weirddemon View Post
    ...
    I forgot to mention that when the app is opened, it expands completely, but the top left is offset for some reason. Also, resizing the window to make it smaller or clicking the maximize button for the console screws it up.
    Which is why you see the check for the f5 key in the loop.
    If you resize the form, press f5 to recalculate the height and width, so the characters fall vertically again.

  12. #12
    Member
    Join Date
    Mar 2015
    Posts
    51

    Re: Matrix Effect

    Quote Originally Posted by passel View Post
    If you have a Visual Basic .Net Development environment, simply choose to create a new project, and select Console Application.
    You should see the template code generated (Module1 and Sub Main), as is in the first post.
    Paste the code from the first post in place of the template code.
    It says it is a console application on the first line of the first post.

    Thank you,
    This is an awesome app

  13. #13
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: Matrix Effect

    Here's a way to have your forms in an app have falling snowflakes:
    vb Code:
    1. Option Explicit On
    2. Option Strict On
    3. Option Infer Off
    4.  
    5. Imports System.ComponentModel
    6. Imports System.Drawing.Drawing2D
    7.  
    8. Public Class SnowBaseForm
    9.  
    10.     Private Shared ReadOnly Random As New Random()
    11.  
    12.     Private Shared ReadOnly m_SnowFlakes As New List(Of SnowFlake)
    13.     Private WithEvents Timer1 As System.Windows.Forms.Timer
    14.  
    15.     Private m_Tick As Integer = 0I
    16.     Private m_Snow As Bitmap
    17.  
    18. #Region " Constructor "
    19.  
    20.     Public Sub New()
    21.  
    22.         ' This call is required by the Windows Form Designer.
    23.         Call InitializeComponent()
    24.  
    25.         ' Add any initialization after the InitializeComponent() call.
    26.  
    27.         'We paint our control ourself and need a double buffer to prevent flimmering
    28.         Me.SetStyle(ControlStyles.UserPaint Or ControlStyles.AllPaintingInWmPaint Or ControlStyles.DoubleBuffer, True)
    29.         Timer1 = New System.Windows.Forms.Timer
    30.         Timer1.Interval = 20I
    31.     End Sub
    32.  
    33. #End Region
    34. #Region " BaseForm: Paint, Dispose "
    35.  
    36.     'Form overrides dispose to clean up the component list.
    37.     <System.Diagnostics.DebuggerNonUserCode()> _
    38.     Protected Overrides Sub Dispose(ByVal disposing As Boolean)
    39.         Try
    40.             If disposing AndAlso components IsNot Nothing Then
    41.                 components.Dispose()
    42.             End If
    43.             If disposing Then
    44.                 Timer1.Enabled = False
    45.                 Timer1.Dispose()
    46.             End If
    47.         Finally
    48.             MyBase.Dispose(disposing)
    49.         End Try
    50.     End Sub
    51.  
    52.     <System.Diagnostics.DebuggerNonUserCode()> _
    53.     Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
    54.         MyBase.OnPaint(e)
    55.         Dim g As Graphics = e.Graphics
    56.         g.SmoothingMode = SmoothingMode.HighSpeed
    57.         'other things may be to slow
    58.         For Each s As SnowFlake In m_SnowFlakes
    59.             g.ResetTransform()
    60.             g.TranslateTransform(-16I, -16I, MatrixOrder.Append)
    61.             'Align our flakes to the center
    62.             g.ScaleTransform(s.Scale, s.Scale, MatrixOrder.Append)
    63.             'Scale them..
    64.             g.RotateTransform(s.Rotation, MatrixOrder.Append)
    65.             'Rotate them..
    66.             g.TranslateTransform(s.X, s.Y, MatrixOrder.Append)
    67.             'Move them to their appropriate location
    68.             'draw them
    69.             g.DrawImage(Snow, 0I, 0I)
    70.         Next s
    71.     End Sub
    72.  
    73. #End Region
    74. #Region " Properties "
    75.  
    76.     Private ReadOnly Property Snow() As Bitmap
    77.         Get
    78.             If m_Snow Is Nothing Then
    79.                 'First Time - Create Image
    80.                 m_Snow = New Bitmap(32I, 32I)
    81.  
    82.                 Using g As Graphics = Graphics.FromImage(m_Snow)
    83.                     g.SmoothingMode = SmoothingMode.AntiAlias
    84.                     g.Clear(Color.Transparent)
    85.  
    86.                     g.TranslateTransform(16.0F, 16.0F, MatrixOrder.Append)
    87.  
    88.                     Dim black As Color = Color.FromArgb(1I, 1I, 1I)
    89.                     Dim white As Color = Color.FromArgb(255I, 255I, 255I)
    90.  
    91.                     DrawSnow(g, New SolidBrush(black), New Pen(black, 3.0F))
    92.                     DrawSnow(g, New SolidBrush(white), New Pen(white, 2.0F))
    93.  
    94.                     g.Save()
    95.                 End Using
    96.             End If
    97.  
    98.             Return m_Snow
    99.         End Get
    100.     End Property
    101.  
    102.     <Category("Snow"), DefaultValue("True")> _
    103.     Public Property Snowing() As Boolean
    104.         Get
    105.             Return Timer1.Enabled
    106.         End Get
    107.         Set(ByVal value As Boolean)
    108.             If value <> Timer1.Enabled Then Timer1.Enabled = value
    109.         End Set
    110.     End Property
    111.  
    112.     <Category("Snow"), DefaultValue(20)> _
    113.     Public Property SnowSpeed() As Integer
    114.         Get
    115.             Return IntervalToSnowSpeed(Timer1.Interval)
    116.         End Get
    117.         Set(ByVal value As Integer)
    118.             Select Case value
    119.                 Case Is > 41I : value = 41I
    120.                 Case Is < 1I : value = 1I
    121.             End Select
    122.             Timer1.Interval = SnowSpeedToInterval(value)
    123.         End Set
    124.     End Property
    125.  
    126. #End Region
    127. #Region " Methods "
    128.  
    129.     Public Sub StartSnow()
    130.         Timer1.Start()
    131.     End Sub
    132.  
    133.     Public Sub StopSnow()
    134.         Timer1.Stop()
    135.     End Sub
    136.  
    137.     Public Sub ClearSnow()
    138.         m_SnowFlakes.Clear()
    139.         m_Tick = 0I
    140.         Me.Refresh()
    141.     End Sub
    142.  
    143. #End Region
    144. #Region " Conversion Functions "
    145.  
    146.     Private Function SnowSpeedToInterval(ByVal Speed As Integer) As Integer
    147.         Dim output As Integer = 10I
    148.         Select Case Speed
    149.             Case 0I : output = 50I
    150.             Case 1I : output = 49I
    151.             Case 2I : output = 48I
    152.             Case 3I : output = 47I
    153.             Case 4I : output = 46I
    154.             Case 5I : output = 45I
    155.             Case 6I : output = 44I
    156.             Case 7I : output = 43I
    157.             Case 8I : output = 42I
    158.             Case 9I : output = 41I
    159.             Case 10I : output = 40I
    160.             Case 11I : output = 39I
    161.             Case 12I : output = 38I
    162.             Case 13I : output = 37I
    163.             Case 14I : output = 36I
    164.             Case 15I : output = 35I
    165.             Case 16I : output = 34I
    166.             Case 17I : output = 33I
    167.             Case 18I : output = 32I
    168.             Case 19I : output = 31I
    169.             Case 20I : output = 30I
    170.             Case 21I : output = 29I
    171.             Case 22I : output = 28I
    172.             Case 23I : output = 27I
    173.             Case 24I : output = 26I
    174.             Case 25I : output = 25I
    175.             Case 26I : output = 24I
    176.             Case 27I : output = 23I
    177.             Case 28I : output = 22I
    178.             Case 29I : output = 21I
    179.             Case 30I : output = 20I
    180.             Case 31I : output = 19I
    181.             Case 32I : output = 18I
    182.             Case 33I : output = 17I
    183.             Case 34I : output = 16I
    184.             Case 35I : output = 15I
    185.             Case 36I : output = 14I
    186.             Case 37I : output = 13I
    187.             Case 38I : output = 12I
    188.             Case 39I : output = 11I
    189.             Case 40I : output = 10I
    190.         End Select
    191.         Return output
    192.     End Function
    193.  
    194.     Private Function IntervalToSnowSpeed(ByVal Interval As Integer) As Integer
    195.         Dim output As Integer = 1I
    196.         Select Case Interval
    197.             Case 50I : output = 0I
    198.             Case 49I : output = 1I
    199.             Case 48I : output = 2I
    200.             Case 47I : output = 3I
    201.             Case 46I : output = 4I
    202.             Case 45I : output = 5I
    203.             Case 44I : output = 6I
    204.             Case 43I : output = 7I
    205.             Case 42I : output = 8I
    206.             Case 41I : output = 9I
    207.             Case 40I : output = 10I
    208.             Case 39I : output = 11I
    209.             Case 38I : output = 12I
    210.             Case 37I : output = 13I
    211.             Case 36I : output = 14I
    212.             Case 35I : output = 15I
    213.             Case 34I : output = 16I
    214.             Case 33I : output = 17I
    215.             Case 32I : output = 18I
    216.             Case 31I : output = 19I
    217.             Case 30I : output = 20I
    218.             Case 29I : output = 21I
    219.             Case 28I : output = 22I
    220.             Case 27I : output = 23I
    221.             Case 26I : output = 24I
    222.             Case 25I : output = 25I
    223.             Case 24I : output = 26I
    224.             Case 23I : output = 27I
    225.             Case 22I : output = 28I
    226.             Case 21I : output = 29I
    227.             Case 20I : output = 30I
    228.             Case 19I : output = 31I
    229.             Case 18I : output = 32I
    230.             Case 17I : output = 33I
    231.             Case 16I : output = 34I
    232.             Case 15I : output = 35I
    233.             Case 14I : output = 36I
    234.             Case 13I : output = 37I
    235.             Case 12I : output = 38I
    236.             Case 11I : output = 39I
    237.             Case 10I : output = 40I
    238.         End Select
    239.         Return output
    240.     End Function
    241.  
    242. #End Region
    243. #Region " Timer1_Tick "
    244.  
    245.     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    246.         'Tick..
    247.         If m_Tick = Integer.MaxValue Then m_Tick = 0I
    248.         m_Tick += 1I
    249.  
    250.         'Spawn new Flakes
    251.         If m_Tick Mod 3I = 0I AndAlso Random.NextDouble() < 0.7R Then
    252.             Dim s As New SnowFlake()
    253.             s.X = Random.Next(-50I, Width + 50I)
    254.             'All over the screen...
    255.             s.Y = Random.Next(-20I, -7I)
    256.             'Customize height further
    257.             s.XVelocity = CSng((Random.NextDouble() - 0.5F)) * 2.0F
    258.             s.YVelocity = CSng((Random.NextDouble() * 3.0F)) + 1.0F
    259.             s.Rotation = Random.Next(0I, 359I)
    260.             s.RotVelocity = Random.Next(-3I, 3I) * 2.0F
    261.  
    262.             If s.RotVelocity.Equals(0.0F) Then s.RotVelocity = 3.0F
    263.  
    264.             s.Scale = CSng((Random.NextDouble() / 2I)) + 0.75F
    265.             m_SnowFlakes.Add(s)
    266.         End If
    267.  
    268.         'Move current flakes (and add them to del list, if they exceed the screen)
    269.         Dim del As New List(Of SnowFlake)
    270.         For Each s As SnowFlake In m_SnowFlakes
    271.             s.X += s.XVelocity
    272.             s.Y += s.YVelocity
    273.             s.Rotation += s.RotVelocity
    274.  
    275.             'Make them move snowflake like
    276.             s.XVelocity += (CSng(Random.NextDouble()) - 0.5F) * 0.7F
    277.             s.XVelocity = Math.Max(s.XVelocity, -2.0F)
    278.             s.XVelocity = Math.Min(s.XVelocity, 2.0F)
    279.  
    280.             If s.YVelocity > Me.Height + 10I Then
    281.                 'Out of Screen
    282.                 del.Add(s)
    283.             End If
    284.         Next s
    285.  
    286.         'Delete them
    287.         For Each s As SnowFlake In del
    288.             m_SnowFlakes.Remove(s)
    289.         Next s
    290.  
    291.         'Redraw our control
    292.         Me.Refresh()
    293.     End Sub
    294.  
    295. #End Region
    296. #Region " Helpers "
    297.  
    298.     ''' <summary>
    299.     '''     Draws a snow flake on the specified graphics object
    300.     ''' </summary>
    301.     ''' <param name="g">Graphics object to draw on</param>
    302.     ''' <param name="b">Brush (Color) of the middle part</param>
    303.     ''' <param name="p">Pen (Color, Size) of the lines</param>
    304.     Private Shared Sub DrawSnow(ByVal g As Graphics, ByVal b As Brush, ByVal p As Pen)
    305.         Const a As Integer = 6I
    306.         Const a2 As Integer = a + 2I
    307.         Const r As Integer = 2I
    308.  
    309.         g.DrawLine(p, -a, -a, +a, +a)
    310.         g.DrawLine(p, -a, +a, +a, -a)
    311.  
    312.         g.DrawLine(p, -a2, 0I, +a2, 0I)
    313.         g.DrawLine(p, 0I, -a2, 0I, +a2)
    314.  
    315.         g.FillEllipse(b, -r, -r, r * 2I, r * 2I)
    316.     End Sub
    317.  
    318. #End Region
    319. #Region " Classes "
    320.  
    321.     ''' <summary>
    322.     ''' This Container class represents the snowflake falling and rendered to the screen
    323.     ''' </summary>
    324.     Private Class SnowFlake
    325.         Public Rotation As Single
    326.         Public RotVelocity As Single
    327.         Public Scale As Single
    328.         Public X As Single
    329.         Public XVelocity As Single
    330.         Public Y As Single
    331.         Public YVelocity As Single
    332.     End Class
    333.  
    334. #End Region
    335.  
    336. End Class
    Just have your forms inherit from SnowBaseForm instead of System.Windows.Forms.Form
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  14. #14
    Lively Member
    Join Date
    Nov 2015
    Location
    Wilmington,NC
    Posts
    72

    Re: Matrix Effect

    awesome thanks!!

  15. #15
    New Member
    Join Date
    Sep 2016
    Posts
    2

    Re: Matrix Effect

    thanks op for code snippet...i want to give back by providing two alternative solutions: 1) re-initialize when height or width of console changed (instead of when F5 is pressed), 2) implement within a WPF application

    alt solution 1: re-initialize when height or width of console changed (instead of when F5 is pressed)

    1) declare a width and height variable before the whileloop
    2) within while loop, save height and width of console
    3) within while loop, modify if/then clause to initialize if current (new) console height/width is not the same as console's last height/width

    Code:
                    Dim lastConsoleWidth, lastConsoleHeight As Integer
                    While True
                        lastConsoleWidth = Console.WindowWidth
                        lastConsoleHeight = Console.WindowHeight
                        Dim t1 As DateTime = DateTime.Now
                        MatrixStep(width, height, y, l)
                        ms = 10 - CInt(Math.Truncate(CType(DateTime.Now - t1, TimeSpan).TotalMilliseconds))
                        If ms > 0 Then
                            System.Threading.Thread.Sleep(ms)
                        End If
                        If Console.WindowHeight <> lastConsoleHeight Or Console.WindowWidth <> lastConsoleWidth Then
                            Initialize(width, height, y, l)
                        End If
                    End While
    alt solution 2: implement within a WPF application
    1) create class Win32 (source: http://stackoverflow.com/questions/2...-console-in-vb)
    2) don't forget to declare your global variables
    Code:
        Dim thistime As Boolean = False
        Dim m_r As New Random()
    2) call Win32.AllocConsole() wherever/whenever you want console to run
    Code:
    Win32.AllocConsole()
    Code:
        Public Class Win32
            <DllImport("kernel32.dll")> Public Shared Function AllocConsole() As Boolean
    
            End Function
            <DllImport("kernel32.dll")> Public Shared Function FreeConsole() As Boolean
    
            End Function
    
        End Class

Posting Permissions

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



Click Here to Expand Forum to Full Width