So, on my school we have started with Visual Basic and I found it quite fun so I'd thought I'll continue on it. Right now I have a project that I hope is going to be a better version of the Windows Command Prompt(will probably never get finished, but you never know).
Anyway, when I put in a command in the input box and hit enter it separates the parts of the command. For example when I write "test command with parameters" it split them up to "test", "command", "with", "parameters". So if I have it so it checks if there is written "command" after "test" it works, but if I just writes "test" I get an error that it is checking for a variable that doesn't exist.
It is probably easier to just post the code so here it is
' Initsialize local variables and arrays
Dim input As String
Dim SeperateInput() As String
' Set "input" variable to input value
input = Me.input.Text
' If Input is empty
If Me.input.Text = "" Then
Else
' Split up input to parts, seperated by a space character
SeperateInput = Split(CStr(input), " ")
' Set input box to empty
Me.input.Text = vbNullString
' Add a new command line to the output box
Me.output.Text = output.Text & vbNewLine & ">" & input
' This is all available commands
If SeperateInput(0) = "cls" Then
Me.output.Text = vbNullString
End If
If SeperateInput(0) = "exit" Then
If SeperateInput(1) = "/b" Then #This is just an example but it is here the error is. But only when don't write anything more than exit.
Me.output.Text = "TEST"
End If
Close()
End If
If SeperateInput(0) = "about" Then
Me.output.Text = vbNullString
Me.output.Text = "Terminal Command Prompt" & vbNewLine & "Made by Markus Rosensköld"
End If
End If
I guess it is the array(or what you call it in VB) that is the problem. That it checks for text in an array-part that isn't there, but is there any way to fix it?
I have only been working with Visual Basic for like 4 days so please bear with me.