Command Prompt Style Application
Use this board to post your code snippets - tips and tricks
6 posts
Page 1 of 1
A simple module to show you how to create a command prompt style application
Code: Select all
Module Module1
Dim a As Integer
Dim b As Integer
Dim c As Integer
Sub Main()
Console.WriteLine("Type ! for help Creator:Chris Johnson Email:chris-johnson11@hotmail.com")
a = 0
b = 0
c = 0
start()
End Sub
Sub start()
Dim s As String
Console.Write(">")
s = Console.ReadLine
If s = "#a" Then numa() Else
If s = "#b" Then numb() Else
If s = "@" Then compile() Else
If s = "a" Then MsgBox("#A is " & a, MsgBoxStyle.Information, "#A") Else
If s = "b" Then MsgBox("#B is " & b, MsgBoxStyle.Information, "#B") Else
If s = "!" Then help() Else
If s = "clr" Then Console.Clear() : Main() Else
Console.WriteLine("That is not a command type: ! for help")
start()
End Sub
Sub numa()
Console.Write("Vaule For integer A:")
Try
a = Console.ReadLine
Catch
Console.WriteLine("Please Enter A Number")
numa()
End Try
start()
End Sub
Sub numb()
Console.Write("Vaule For Integer B:")
Try
b = Console.ReadLine()
Catch
Console.WriteLine("Please Emter A Number")
numb()
End Try
start()
End Sub
Sub help()
Console.WriteLine("Commands:")
Console.WriteLine("!-Get Help")
Console.WriteLine("#a-Sets Vaule Of Integer a ")
Console.WriteLine("#b-Sets Vaule Of Integer b ")
Console.WriteLine("@-choose operation")
Console.WriteLine("a-view vaule of the a integer")
Console.WriteLine("a-view vaule of the b integer")
Console.WriteLine("clr-Clear Window")
start()
End Sub
Sub compile()
Dim s As String
Console.Write("What Operation(+,-,x,/):")
s = Console.ReadLine
If s = "+" Then c = a + b Else
If s = "-" Then c = a - b Else
If s = "x" Then c = a * b Else
If s = "/" Then c = a / b Else
Console.WriteLine("Out: " & c)
start()
End Sub
End Module
Please us the ' character to comment your lines so people can learn from it.
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
If you are smart you can use logic to figure out what the code is doing.
mandai wrote:If you are smart you can use logic to figure out what the code is doing.It would thenagain be a code snippet instead of a tut. A tut is used to explain the usage of a piece of code, but correct me if im wrong though.
Practice makes perfect!
VIP since: 6-10-2011
VIP since: 6-10-2011
6 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023