Sub Main()
If (getBookPrice() > 49.99) Then
Console.WriteLine("Woah, that book is expensive")
Else
Console.WriteLine("That is not too expensive")
End If
Console.ReadLine()
End Sub
Function getBookPrice() As Double
Dim price As Double
Console.WriteLine("What is the price of the book?")
price = Console.ReadLine()
Return price
End Function
Here is a tutorial that finds the squares of 1-19 using a function
Sub main()
Dim i As Integer
Console.WriteLine("Number " & vbTab & "Square " & vbCrLf)
For i = 1 To 19
Console.WriteLine(i & vbTab & square(i))
Next
Console.ReadLine()
End Sub
Function square(ByVal y As Integer) As Integer
Return y ^ 2
End Function
Here is a tutorial on finding the maximum value out of three numbers
Sub main()
Dim value1, value2, value3 As Double
value1 = Console.ReadLine()
value2 = Console.ReadLine()
value3 = Console.ReadLine()
Console.WriteLine(Maximum(value1, value2, value3))
Console.ReadLine()
End Sub
Function maximum(ByVal valueOne As Double, ByVal valueTwo As Double, ByVal valueThree As Double) As Double
Return Math.Max(Math.Max(valueOne, valueTwo), valueThree)
End Function
Here is a tutorial from Michael Halverston on creating a new form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim form2 As New Form
'define the text property and border style of the form
form2.Text = "My New Form"
form2.FormBorderStyle = FormBorderStyle.FixedDialog
'specify that the position of the form will be set manually
form2.StartPosition = FormStartPosition.Manual
'Declare a rectangle structure to hold the form dimensions
Dim form2Rect As New Rectangle(400, 200, 300, 350)
'set the bounds of the form using the Rectangle object
form2.DesktopBounds = form2Rect
'display the form as a modal dialog box
form2.ShowDialog()
End Sub
No comments:
Post a Comment