Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Demo()
- Dim grade As Integer
- grade = 4
- If grade >= 5 Then
- Debug.Print "Excellent"
- End If
- End Sub
- =====================================
- Sub Demo()
- Dim greater As Integer
- greater = GreaterNum(2, 2)
- Debug.Print greater
- End Sub
- Function GreaterNum(firstNum, secondNum As Integer)
- If firstNum >= secondNum Then
- 'GreaterNum = firstNum
- MsgBox firstNum
- Else
- MsgBox secondNum
- 'GreaterNum = secondNum
- End If
- End Function
- =====================================
- Sub Demo()
- Dim result As String
- result = EvenOrOdd(2)
- Debug.Print result
- End Sub
- Function EvenOrOdd(num As Integer)
- If num Mod 2 = 0 Then
- EvenOrOdd = "even"
- 'MsgBox "even"
- Else
- EvenOrOdd = "odd"
- 'MsgBox "odd"
- End If
- End Function
- =====================================
- Sub Demo()
- Dim num As Integer
- num = 13
- Dim digitAsText As String
- If num = 1 Then
- digitAsText = "one"
- ElseIf num = 2 Then
- digitAsText = "two"
- ElseIf num = 3 Then
- digitAsText = "three"
- ElseIf num = 4 Then
- digitAsText = "four"
- ElseIf num = 5 Then
- digitAsText = "five"
- ElseIf num = 6 Then
- digitAsText = "six"
- ElseIf num = 7 Then
- digitAsText = "seven"
- ElseIf num = 8 Then
- digitAsText = "eight"
- ElseIf num = 9 Then
- digitAsText = "nine"
- Else
- digitAsText = "not a digit"
- End If
- Debug.Print digitAsText
- End Sub
- =====================================
- Sub Demo()
- Dim num As Integer
- num = 20000
- Dim result As String
- If num < 100 Then
- result = "Less than 100"
- ElseIf num <= 200 Then
- result = "Between 100 and 200"
- Else
- result = "Greater than 200"
- End If
- Debug.Print result
- End Sub
- =====================================
- Sub Demo()
- Dim inputText As String
- inputText = "s3cr3t!P@ssw0rd"
- Dim result As String
- If inputText = "s3cr3t!P@ssw0rd" Then
- result = "Welcome"
- Else
- result = "Wrong password!"
- End If
- Debug.Print result
- End Sub
- =====================================
- Sub Demo()
- Dim result As Double
- result = ReturnArea("circle", 10)
- Debug.Print result
- End Sub
- Function ReturnArea(typeFigure As String, param As Double)
- Select Case (typeFigure)
- Case "square"
- ReturnArea = param * param
- Case "circle"
- ReturnArea = WorksheetFunction.Pi * param * param
- End Select
- End Function
- =====================================
- Sub Demo()
- Dim tripPrice, countPuzzle, countDolls, countTeddy, countMinions, countTrucks As Double
- tripPrice = 320
- countPuzzle = 8
- countDolls = 2
- countTeddy = 5
- countMinions = 5
- countTrucks = 1
- Dim allToysPrice As Double
- allToysPrice = (countPuzzle * 2.6) + (countDolls * 3) + (countTeddy * 4.1) + (countMinions * 8.2) + (countTrucks * 2)
- Dim countAllToys As Double
- countAllToys = countPuzzle + countDolls + countTeddy + countMinions + countTrucks
- If countAllToys > 50 Then
- allToysPrice = allToysPrice * 0.75
- End If
- allToysPrice = allToysPrice * 0.9
- Dim diff As Double
- diff = Abs(allToysPrice - tripPrice)
- If allToysPrice >= tripPrice Then
- Debug.Print "Yes! " & diff & " lv left."
- Else
- Debug.Print "Not enough money! " & diff & " lv needed."
- End If
- End Sub
- =====================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement