Code, Design and Applications
There are two kinds of procedures: functions and subroutines (sometimes called subs). A function returns a value to the procedure that called it, whereas a sub simply executes code.
When you say SUB, it contains all your secret commands for the computer to interpret it later ALL AT ONCE.
Sub MyFirstSub()
'CODE HERE ALL AT ONCE
End Sub
At Functions, there's a return value e.g. TRUE OR FALSE, STRING OR INTEGER
Function MyFirstFunction() As Integer
'if false return 0
Dim Satisfy As Integer
If Satisfy = 1 Then
'CODE HERE FOR SATISTY
Return 1
Exit Function
End If
'CODE HERE FOR FALSE SATISFY
Return 0 'at the end return 1
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call PlaySound("Startup.wav", 1)
End Sub
Sub PlaySound(ByVal SoundFile As String, ByVal Volume As Integer)
My.Computer.Audio.Play(SoundFile, Volume)
End Sub
First, you need to declare the variable as any datatype and then connect it to textboxes for input.
Function AddTwoNumbers(ByVal N1 As Integer, ByVal N2 As Integer) As Integer
Return N1 + N2
End Function
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim aNumber As Integer = CInt(Textbox1.Text)
Dim bNumber As Integer = CInt(Textbox2.Text)
MessageBox.Show(AddTwoNumbers(aNumber, bNumber))
End Sub
FAMOUS DATA TYPES
String means any group of characters e.g. "My Name"
Integer 1 or 0 logic and no decimal e.g. 0-10,000
Boolean False or True Logic
Single Any number with decimal places
Double Double digit with Single DataType
RADIO BUTTON CONTROL
Drag and Drop the Radio Button and Button Control to the Form and Double Click the Button After configuring the Text at the Properties Window.
If RadioButton3.Checked = True Then
MsgBox("You chose a thin crust")
End If
PICTURE BOX SAMPLE CODE
PictureBox1.ImageLocation = "C:\ShellCities\Electronics Desktop\search.png"
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
MAKING YOUR PROGRAM REPEAT ACTIONS: FOR NEXT LOOP
The For...Next loop allows you to specify a number, and then repeat code contained within that loop for the specified number of times.
Dim i As Integer = 0
Dim NumberOfRepetitions As Integer = CInt(TextBox1.Text)
For i = 1 To NumberOfRepetitions
MessageBox.Show("This line has been repeated " & i & " times")
Next