Visual Basic

From s23
Jump to navigation Jump to search

On Windows, put:

Module HalloWelt 
	
	Sub Main() 
	Console.WriteLine("Hallo, Welt!") 
	End Sub

End Module 

in a textfile with any texteditor, save it as fnord.vb

then on a cmd.exe ,type:

C:\%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\vbc.exe fnord.vb

(or wherever you have vbc.exe, which is the visual basic compiler) (*)


(*) If you cant find vbc.exe on your box you need to install .Net Framework, you dont need the complete SDK, that is optional.


.. and you will have a new fnord.exe and compiled your own windows commandline executable.

C:\fnord.exe Hallo, Welt!

ergo: also on Windows you dont need a GUI to create applications.

Beispiel Nettoberechnung[edit]

' Berechnet Nettobetrag aus Bruttobetrag und Steuersatz


Imports System.Console

Module T1

	Sub Main()
	  Dim br as Double
	  Dim st as Double
	  Dim netto as Double
	  Dim nochmal as String
	
	WriteLine("'Programm T1' - Berechnet Nettobetrag aus Bruttobetrag und Steuersatz")
	
	 DO 
	   br=0

	     DO WHILE br <= 0
	        WriteLine("Bitte einen Bruttobetrag eingeben. (Der Bruttobetrag muss > 0 sein.): ")
	        br=ReadLine():
	     LOOP
	
	   st=0
	
	     DO WHILE st <= 0 OR st > 100
	        WriteLine("Bitte einen Steuersatz in Prozent eingeben (Steuer muss > 0 und <= 100 sein!) %: ")
	        st=ReadLine():
	     LOOP
	
	   netto=br-(br/100*st)
	   Write("Der Nettobetrag ist: ")
	   WriteLine(Netto)
	   Write("Nochmal rechnen? (j/n): ")
	   nochmal=ReadLine():
	
	 LOOP UNTIL nochmal="n"
	
	End Sub

End Module