Saturday, January 24, 2009

First code in VB .NET!

Module Module1
Sub Main()
'to make a variable ... Dim variable1 As
'Console write line!
'Console read line!
'This is a comment. You use comments so other programmers
'can know what you mean!!
'Miles Per Gallon Calculator!
Dim miles As Decimal
Dim gallons As Decimal
Dim mpg As Decimal
Console.WriteLine("Please enter the distance in miles:")
miles = Console.ReadLine
Console.WriteLine("Please enter the gallons used:")
gallons = Console.ReadLine
' We need to calculate the miles per gallon!
mpg = miles / gallons
Console.WriteLine(mpg)
'Console.ReadLine()
'to see if we have the correct information
'100 miles / 10 gallons of gas -> 10 mpg
End Sub
End Module

No comments: