OneCompiler

Em

207

MsgBox"hello World!"
1(button and msg box)

Sub AddNumbers() Dim Total As Integer Dim Count As Integer Total = 0
For Count = 1 To 10 Total = Total + Count Next Count
MsgBox Total End Sub
2(Program to wrk with loops)....

Private Sub Constant_demo_Click()
Dim a As Integer a = 5
Dim b As Integer b = 10
Dim c As Double c = a + b
MsgBox ("Addition Result is " & c) c = a - b
MsgBox ("Subtraction Result is " & c) c = a * b
MsgBox ("Multiplication Result is " & c) c = b / a
MsgBox ("Division Result is " & c) c = b Mod a
MsgBox ("Modulus Result is " & c)
c = b ^ a
MsgBox ("Exponentiation Result is " & c) End Sub
4(Arithmetic & logical operation)...

Dim text1 As String, text2 As String text1 = "Hi"
text2 = "Tim"
MsgBox text1 & " " & text2 Dim text As String
text = "example text" MsgBox Left(text, 4)
MsgBox Right("example text", 2) MsgBox Mid("example text", 9, 2) MsgBox Len("example text")
MsgBox Instr("example text", "am")
7(To perform string manipulation)

cellwords = 0
totalwords = 0
For Each Cell In rng
If Not Cell.HasFormula Then content = cell.value
content = Trim(content) If content = “ “ Then cellwords = 0
Else Cellwords = 1 End If
End If
Do While InStr(content, “ “)>0
content = Mid(content,InStr(content, ” “)) content = Trim(content)
cellword = cellword + 1 Loop
totalwords = totalwords + cellwords Next cell
MsgBox totalwords & “Words found in the selected range” End Sub
8(To count number of words in a given Sentence)

Sub AA()
Dim A as Integer Dim B As Integer Dim C As Integer Dim D As Integer Dim result As Integer A = 12
B = 25
C = 36
D = 45
result = WorksheetFunction.Max(A, B, C, D) MsgBox result
End Sub

9(to find minimum and maximum values)