Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Simple "animated" console menu

Hello HF!
I have made a simple console program because i needed it for a school project and i want a simple menu base that isnt based on number imput but something more interesting

As my coding skills... well are limited i am asking for any advice on how to improve this code, i made it so it works it didnt need to be really tidy.
I didnt post any screenshots because you can just c/p it into VS and see it for yourself, no editing needed
It just gets the currently selected index and parses it to a simple sub that selects the case and executes the code that u need
Code
Dim lin As List(Of String)
    Dim index As Integer = 0
    Dim Lindex As Integer = Nothing
    Dim spacer1 As String = "[x"
    Dim spacer2 As String = "x]"
    Sub New()
        lin = New List(Of String)
        lin.Add("HELLO I AM OPTION")
        lin.Add("HELLO I AM OPTION")
        lin.Add("HELLO I AM OPTION")

    End Sub

    Sub Main()

        Dim cki As ConsoleKeyInfo
        ' Prevent example from ending if CTL+C is pressed.
        Console.TreatControlCAsInput = True
        Do
            Dim lnght As Integer = lin.Count - 1
            cki = Console.ReadKey()

            If cki.Key.ToString.Contains("Up") Then
                If index < 1 = False Then
                    index -= 1
                End If
            End If
            If cki.Key.ToString.Contains("Down") Then
                If index < lnght Then
                    index += 1
                End If
            End If
            If cki.Key.ToString.Contains("Enter") Then
                selectedFunction(index)

            End If
            If Lindex = index Then GoTo skip
            Console.Clear()

            For i = 0 To lnght
                If i = index Then
                    Console.WriteLine(spacer1 & lin(i) & spacer2)
                Else
                    Console.WriteLine(lin(i))
                End If

            Next
            Lindex = index
skip:
        Loop While cki.Key <> ConsoleKey.Escape
    End Sub

    Sub selectedFunction(ins As Integer)
        Select Case ins
            Case 1
            Case 2
            Case 3
            Case 4
        End Select
    End Sub


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Shell] by Emre_Sep 1, 2019 07:17 PM 0 134 Sep 1, 2019 07:17 PM
Last Post: Emre_
[C#] by LaTortueSep 1, 2018 09:00 PM 2 199 Sep 1, 2018 09:00 PM
Last Post: vagabond
[C] by Kali_ShadowJul 2, 2018 05:55 AM 19 582 Jul 2, 2018 05:55 AM
Last Post: Kali_Shadow