Dec 22, 2015 07:18 AM
(This post was last modified: Dec 22, 2015 07:23 AM by N3w8i3H4ck3r.)
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
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
