Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 45

Palindrome Private Sub Command1_Click() If StrReverse(Text1.Text) = Text1.

Text Then MsgBox ("string is palidrome") Else MsgBox ("string is not palindrome") End If End Sub

simple interest Private Sub Command1_Click() Dim a As Integer Dim b As Integer Dim c As Integer Dim d As Double a = Val(Text1.Text) b = Val(Text2.Text) c = Val(Text3.Text) d = (a * b * c) / 100 Text4.Text = d End Sub

cut copy paste Private Sub Command1_Click() Text2.SelText = Clipboard.GetText() End Sub Private Sub Command2_Click() Clipboard.Clear Clipboard.SetText (Text1.SelText) End Sub Private Sub Command3_Click() Clipboard.Clear Clipboard.SetText (Text1.SelText) Text1.SelText = "" End Sub

add two no Dim x, y, z As Integer Private Sub cmd3_Click() t1.Text = "" t2.Text = "" t3.Text = "" End Sub Private Sub Command1_Click() x = Val(t1.Text) y = Val(t2.Text) z=x+y t3.Text = z End Sub Private Sub Command2_Click() 'Unload Me End End Sub

common dialogue box picture Private Sub Command1_Click() CommonDialog1.ShowOpen End Sub Private Sub Command10_Click() Picture1.Picture = LoadPicture("") End Sub Private Sub Command2_Click() CommonDialog1.Filter = "All files|*.*|text files|*.txt|batch files|*.bat" CommonDialog1.FilterIndex = 1 CommonDialog1.ShowSave End Sub Private Sub Command3_Click() CommonDialog1.ShowColor Form1.BackColor = CommonDialog1.Color End Sub Private Sub Command4_Click() CommonDialog1.ShowFont End Sub Private Sub Command5_Click() CommonDialog1.ShowPrinter End Sub Private Sub Command6_Click() CommonDialog1.ShowHelp End Sub Private Sub Command7_Click() Dim strfile As String CommonDialog1.ShowOpen strfile = CommonDialog1.FileName Picture1.Picture = LoadPicture(strfile) End Sub Private Sub Command8_Click() Dim strfile As String CommonDialog1.ShowSave strfile = CommonDialog1.FileName SavePicture Image, strfile

End Sub Private Sub Command9_Click() Dim strfile As String CommonDialog1.ShowSave strfile = CommonDialog1.FileName SavePicture Image, strfile End Sub

loading Private Sub Form_Load() Dim pnl As Panel Set pn1 = StatusBar1.Panels.Add(2, , , sbrDate) Set pn1 = StatusBar1.Panels.Add(3, , App.Path) End Sub Private Sub Timer1_Timer() ProgressBar1.Value = ProgressBar1.Value + 5 If ProgressBar1.Value = 100 Then Timer1.Enabled = False frmSplash.Show End If End Sub Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case Is = "new" MsgBox ("new") Case Is = "open" MsgBox ("open") Case Is = "save" MsgBox ("save") End Select

Traffic light Private Sub Form_Load() s=0 End Sub Private Sub Timer1_Timer() Static s As Integer Shape1.FillColor = vbBlack Shape2.FillColor = vbBlack Shape3.FillColor = vbBlack If s = 0 Then Shape1.FillColor = vbRed Shape2.FillColor = vbBlack Shape3.FillColor = vbBlack s=1 ElseIf s = 1 Then Shape1.FillColor = vbBlack Shape2.FillColor = RGB(248, 120, 0) Shape3.FillColor = vbBlack s=2 ElseIf s = 2 Then Shape1.FillColor = vbBlack Shape2.FillColor = vbBlack Shape3.FillColor = vbGreen For i = 1 To 520 Image1.Move Image1.Left + i, Image1.Top Next s=0 Image1.Left = 100 End If End Sub

shapes Private Sub HScroll1_Change() Shape1.Shape = HScroll1.Value End Sub Private Sub VScroll1_Change() Shape1.FillStyle = VScroll1.Value End Sub

simple calculator Option Explicit Dim op1, op2, res As Double Dim operator As String Private Sub cmd_add_Click() If op2 = 0 Then op1 = Val(t1.Text) res = op1 + op2 t1.Text = res op2 = res operator = "+" Else op2 = res op1 = Val(t1.Text) res = op1 + op2 t1.Text = res operator = "+" End If End Sub Private Sub cmd_add_LostFocus() t1.Text = "" End Sub Private Sub cmd_clr_Click() t1.Text = " " End Sub Private Sub cmd_div_Click() op1 = Val(t1.Text) t1.Text = "" operator = "/" End Sub Private Sub cmd_equal_Click() op2 = Val(t1.Text) If operator = "+" Then res = op1 + op2 ElseIf operator = "-" Then

res = op1 - op2 ElseIf operator = "/" Then If op2 = 0 Then MsgBox "pl enter non zero no for division" res = 0 Else res = op1 / op2 End If End If t1.Text = res End Sub Private Sub cmd_sub_Click() op1 = Val(t1.Text) t1.Text = "" operator = "-" End Sub Private Sub Command1_Click(Index As Integer) t1.Text = t1.Text + Command1(Index).Caption End Sub

Private Sub Form_Load() op1 = 0 op2 = 0 End Sub

matrix Option Explicit Private Sub cmdAddition_Click() Dim arr1(1, 1) As Integer Dim arr2(1, 1) As Integer Dim arr3(1, 1) As Integer Dim i, j, k As Integer lblOp1.Caption = " +" k=0 For i = 0 To 1 For j = 0 To 1 arr1(i, j) = Val(text1(k).Text) k=k+1 Next j Next i

k=0 For i = 0 To 1 For j = 0 To 1 arr2(i, j) = Val(text2(k).Text) k=k+1 Next j Next i

For i = 0 To 1 For j = 0 To 1 arr3(i, j) = arr1(i, j) + arr2(i, j) Next j Next i lblOp2.Caption = "=" k=0 For i = 0 To 1 For j = 0 To 1 text3(k).Text = arr3(i, j) k=k+1 Next j

Next i End Sub Private Sub cmdExit_Click() End End Sub Private Sub cmdSubtraction_Click() Dim arr1(1, 1) As Integer Dim arr2(1, 1) As Integer Dim arr3(1, 1) As Integer Dim i, j, k As Integer lblOp1.Caption = " -" k=0 For i = 0 To 1 For j = 0 To 1 arr1(i, j) = Val(text1(k).Text) k=k+1 Next j Next i k=0 For i = 0 To 1 For j = 0 To 1 arr2(i, j) = Val(text2(k).Text) k=k+1 Next j Next i For i = 0 To 1 For j = 0 To 1 arr3(i, j) = arr1(i, j) - arr2(i, j) Next j Next i lblOp2.Caption = "=" k=0 For i = 0 To 1 For j = 0 To 1 text3(k).Text = arr3(i, j) k=k+1 Next j Next i End Sub

tables Option Explicit Private Sub Command1_Click() Dim i, k, num, ar1(9) As Integer num = Val(txtInput.Text) If num = 0 Then MsgBox ("Enter the number greater than zero") End If k=0 For i = 1 To 10 Text1(k).Text = num Text3(k).Text = i * num Label5(k).Caption = " * " k=k+1 Next i Label5(10).Caption = " * " End Sub Private Sub Command2_Click() Dim i As Integer txtInput.Text = " " For i = 0 To 9 Text1(i).Text = " " Text3(i).Text = " " Next i End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() Dim i, k As Integer k=0 For i = 1 To 10 Label5(k).Caption = " " Text1(k).Text = " " Text2(k).Text = " " Text2(k).Text = i k=k+1 Next i Label5(10).Caption = " " End Sub

prime no Private Sub cmdCheck_Click() Dim a, i, c As Integer c=1 a = Val(InputBox("Number : ", "Prime")) 'a = Val(a - 1) 'Print a For i = 2 To a - 1 If a Mod i = 0 Then c=0 Exit For End If Next i If c = 0 Then MsgBox ("COMPOSITE NUMBER") Else MsgBox ("PRIME NUMBER") End If End Sub Private Sub cmdExit_Click() End End Sub

square root 'Option Explicit 'use of option explicit in the program Private Sub cmdCalculate_Click() Dim a As Single a = txtInput.Text b = Sqr(a) txtOutput.Text = b End Sub Private Sub cmdExit_Click() End End Sub

list box Private Sub Command1_Click() List1.AddItem (Text1.Text) Text1.Text = "" Text1.SetFocus Label1.Caption = List1.ListCount

End Sub Private Sub Command2_Click() Dim ind As Integer ind = List1.ListIndex If ind >= 0 Then List1.RemoveItem ind Label1.Caption = List1.ListCount Else: Beep End If Command2.Enabled = (List1.ListIndex <> -1) End Sub Private Sub Command3_Click() List1.Clear Command2.Enabled = False Label1.Caption = List1.ListCount End Sub Private Sub Command4_Click() End End Sub Private Sub Form_Load() Command1.Enabled = True End Sub Private Sub List1_Click() Command2.Enabled = List1.ListIndex <> -1 End Sub Private Sub Text1_Change() Command1.Enabled = (Len(Text1.Text) > 0) End Sub

You might also like