0% found this document useful (0 votes)
42 views

Visual Basic

Uploaded by

Snow Thunder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Visual Basic

Uploaded by

Snow Thunder
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 57

Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

1.WAP to design a calculator using VB.


Design window

Dim val1 As Double


Dim val2 As Double
Dim opt As String
Dim cleardisp As Boolean
Private Sub cmdAdd_Click()
val1 = Val(display.Text)
opt = "+"
display.Text = ""
End Sub
Private Sub cmdDiv_Click()
val1 = Val(display.Text)
opt = "/"
display.Text = ""
End Sub
Private Sub cmdDot_Click()
If InStr(display.Text, ".") Then
MsgBox "Don't Press Point Again", vbInformation, "!!Error"
Else
display.Text = display.Text + "."
End If
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Private Sub cmdEqual_Click()


Dim result As Double
val2 = Val(display.Text)
If opt = "+" Then result = val1 + val2
If opt = "-" Then result = val1 - val2
If opt = "X" Then result = val1 * val2
If opt = "/" And val2 <> 0 Then result = val1 / val2
If opt = "sqr" Then result = val1 * val1
If opt = "sqrt" Then result = Sqr(val1)
display.Text = result
End Sub
Private Sub cmdMul_Click()
val1 = Val(display.Text)
opt = "X"
display.Text = ""
End Sub
Private Sub cmdPercent_Click()
val1 = Val(display.Text)
opt = "1/X"
display.Text = ""
End Sub
Private Sub cmdSqrt_Click()
val1 = Val(display.Text)
opt = "sqr"
display.Text = ""
End Sub
Private Sub cmdsqr_Click(Index As Integer)
val1 = Val(display.Text)
opt = "sqr"
display.Text = ""
End Sub
Private Sub cmdSqroot_Click(Index As Integer)
val1 = Val(display.Text)
opt = "sqrt"
display.Text = ""
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

End Sub
Private Sub cmdSub_Click()
val1 = Val(display.Text)
opt = "-"
display.Text = ""
End Sub
Private Sub CommandClear_Click()
display.Text = ""
End Sub
Private Sub digit_Click(Index As Integer)
If cleardisp Then
display.Text = ""
cleardisp = False
End If
display.Text = display.Text + digit(Index).Caption
End Sub
Private Sub Form_Load()
End Sub

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

3.WAP to swap the two numbers by using pass by reference.


Design window
Dim num1 As Integer
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Dim num2 As Integer


Private Sub Command1_Click()
Call swap(Text1.Text, Text2.Text)
End Sub
Public Function swap(val1 As Integer, val2 As Integer)
Dim temp As Integer
temp = val1
val1 = val2
val2 = temp
Text1.Text = val1
Text2.Text = val2
End Function
Private Sub Command2_Click()
End
End Sub
Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

4.Write a program to use check box and option button.


Design Window

Private Sub Check1_Click()


If (Check1.Value = 1) Then
Text1.FontBold = True
Else
Text1.FontBold = False
End If
End Sub
Private Sub Check2_Click()
If (Check2.Value = 1) Then
Text1.FontItalic = True
Else
Text1.FontItalic = False
End If
End Sub
Private Sub Check3_Click()
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

If (Check3.Value = 1) Then
Text1.FontUnderline = True
Else
Text1.FontUnderline = False
End If
End Sub
Private Sub Form_Load()
End Sub
Private Sub Option1_Click()
Text1.FontSize = 10
End Sub
Private Sub Option2_Click()
Text1.FontSize = 12
End Sub
Private Sub Option3_Click()
Text1.FontSize = 14
End Sub
Private Sub Option4_Click()
Text1.ForeColor = vbBlue
End Sub
Private Sub Option5_Click()
Text1.ForeColor = vbGreen
End Sub
Private Sub Option6_Click()
Text1.ForeColor = vbRed
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

6. Program to perform the Drag & Drop operation


Design Window

Private Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)


Picture1.BackColor = vbBlue
End Sub
Private Sub picture1_dragover(Source As Control, X As Single, Y As Single, state As
Integer)
If state = 0 Then
Picture1.BackColor = vbRed
If state = 2 Then
Form1.Caption = "source control moves over the picture box"
If state = 1 Then
Picture1.BackColor = vbGreen
Form1.Caption = "drag & drop demo"
End If
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

7. Program to show the use of MDI (Multiple document interface) form.


Design Window

Private Sub mcascade_Click()


MDIForm1.Arrange vbCascade
End Sub
Private Sub MDIForm_Load()
Form1.Show Form2.Show
Form3.Show
MDIForm1.WindowState = 2
End Sub
Private Sub mhorizontal_Click()
MDIForm1.Arrange vbHorizontal
End Sub
Private Sub mvertical_Click()
MDIForm1.Arrange vbVertical
End Sub

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

8. Program to access the child form in MDI form.


Design Window

Option Explicit
Dim documentforms(10) As New Form1
Private Sub arrange_Click()
arrange 2
End Sub
Private Sub cascade_Click()
arrange 0
End Sub
Private Sub FormOpen_Click()
Dim i As Integer
For i = 0 To 9
documentforms(i).Show
documentforms(i).Caption = "document" & Format(i)
documentforms(i).BackColor = QBColor(Rnd * 14 + 1)
Next i
End Sub
Private Sub FormsClose_Click()
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Dim i As Integer
For i = 0 To 9
Unload documentforms(i)
End Sub
Private Sub horizontal_Click()
arrange 1
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

OUTPUT:

WHEN WE CLICK ON CHILD FORMS AND THEN OPEN FORMS


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

9. Program to show the use of common dialog box.


Design Window

Public newform As frmmain


Private Sub MDIForm_Initialize()
mnueditpaste.Enabled = False
mnueditcut.Enabled = False
mnueditcopy.Enabled = False
mnueditselall.Enabled = False
mnufilesaveas.Enabled = False
standard.Buttons("cut").Enabled = False
standard.Buttons("copy").Enabled = False
standard.Buttons("paste").Enabled = False
standard.Buttons("save").Enabled = False
End Sub
Private Sub MDIForm_Load()
frmmain.Hide
End Sub
Private Sub mnubold_Click()
If newform.txtpad.FontBold = True Then
newform.txtpad.FontBold = False
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Else
newform.txtpad.FontBold = True
End If
End Sub
Private Sub mnubolditalic_Click()
newform.txtpad.FontBold = True
newform.txtpad.FontItalic = True
End Sub
Private Sub mnucolor_Click()
CommonDialog1.ShowColor
newform.txtpad.BackColor = CommonDialog1.Color
End Sub
Private Sub mnueditcopy_Click()
Clipboard.SetText mdiform1.ActiveForm.txtpad.SelText
mnueditpaste.Enabled = True
standard.Buttons("paste").Enabled = True
End Sub
Private Sub mnueditcut_Click()
Clipboard.SetText mdiform1.ActiveForm.txtpad.SelText
mdiform1.ActiveForm.txtpad.SelText = ""
mnueditpaste.Enabled = True
standard.Buttons("paste").Enabled = True
End Sub
Private Sub mnueditpaste_Click()
mdiform1.ActiveForm.txtpad.SelText = Clipboard.GetText
End Sub
Private Sub mnueditselall_Click()
mdiform1.ActiveForm.txtpad.SelStart = 0
mdiform1.ActiveForm.txtpad.SelLength = Len(mdiform1.ActiveForm.txtpad.Text)
mdiform1.ActiveForm.txtpad.SetFocus
End Sub
Private Sub mnufileexit_Click()
End
End Sub
Private Sub mnufilenew_Click()
Set newform = New frmmain
newform.txtpad.Text = ""
newform.Caption = "untitled" & Str(Forms.Count - 2)
mnueditcut.Enabled = True
mnueditcopy.Enabled = True
mnufilesaveas.Enabled = True
mnueditselall.Enabled = True
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

standard.Buttons("cut").Enabled = True
standard.Buttons("copy").Enabled = True
standard.Buttons("save").Enabled = True
sbarnpad.Panels("file").Text = mdiform1.ActiveForm.Caption
newform.Show
End Sub
Private Sub mnufileopen_Click()
CommonDialog1.ShowOpen
End Sub
Private Sub mnufilesaveas_Click()
CommonDialog1.ShowSave
End Sub
Private Sub mnuitalic_Click()
If newform.txtpad.FontItalic = True Then
newform.txtpad.FontItalic = False
Else
newform.txtpad.FontItalic = True
End If
End Sub
Private Sub mnuregular_Click()
newform.txtpad.FontBold = False
newform.txtpad.FontItalic = False
End Sub
Private Sub mnuunderline_Click()
If newform.txtpad.FontUnderline = True Then
newform.txtpad.FontUnderline = False
Else
newform.txtpad.FontUnderline = True
End If
End Sub
Private Sub mnuwincas_Click()
mdiform1.Arrange vbCascade
End Sub
Private Sub mnuwinth_Click()
mdiform1.Arrange vbTileHorizontal
End Sub
Private Sub standard_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "new"
mnufilenew_Click
Case "open"
mnufileopen_Click
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Case "save"
mnufilesaveas_Click
Case "cut"
mnueditcut_Click
Case "copy"
mnueditcopy_Click
Case "paste"
mnueditpaste_Click
End Select
End Sub
Private Sub Timer1_Timer()
Dim num As Integer
num = Forms.Count - 2
If num > 0 Then
sbarnpad.Panels("file").Text = mdiform1.ActiveForm.Caption
Else
sbarnpad.Panels("file").Text = "enjoy mdi notepad"
mnueditpaste.Enabled = False
mnueditcut.Enabled = False
mnueditcopy.Enabled = False
mnueditselall.Enabled = False
mnufilesaveas.Enabled = False
mnufilesaveas.Enabled = False
standard.Buttons("cut").Enabled = False
standard.Buttons("copy").Enabled = False
standard.Buttons("paste").Enabled = False
standard.Buttons("save").Enabled = False
End If
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

10. Program to show the use of rich text box.


Design Window

Dim a As Variant
Private Sub Command1_Click()
RichTextBox1.SelBold = True
End Sub
Private Sub Command10_Click()
MsgBox (RichTextBox1.SelStart)
End Sub
Private Sub Command11_Click()
RichTextBox1.SelLength = Len(RichTextBox1.Text)
MsgBox (RichTextBox1.SelLength)
End Sub
Private Sub Command2_Click()
RichTextBox1.SelItalic = True
End Sub
Private Sub Command3_Click()
RichTextBox1.SelBold = False
RichTextBox1.SelItalic = False
End Sub
Private Sub Command4_Click()
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

RichTextBox1.Text = " "


End Sub
Private Sub Command5_Click()
RichTextBox1.FileName = "C:\Documents and Settings\Administrator.MCA-01\My
Documents\rr3.rtf"
End Sub
Private Sub Command6_Click()
a = RichTextBox1.SelRTF
RichTextBox1.Text = a
End Sub
Private Sub Command7_Click()
a = RichTextBox1.SelText
Print a
End Sub
Private Sub Command8_Click()
RichTextBox1.SelText = UCase(RichTextBox1.SelText)
Print a
End Sub
Private Sub Command9_Click()
RichTextBox1.SelText = "revised string"
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:

11. Program based on timer.


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Design Window

Option Explicit
Dim a, b, l, t, c, col As Integer
Private Sub exit_Click()
End
End Sub
Private Sub Form_Load()
l=0b=0t=0
Timer1.Enabled = False
Text1.Text = " VISUAL BASIC"
Text1.FontBold = True
Text1.BackColor = vbRed
Text1.ForeColor = vbYellow
Text1.FontSize = "20"
Form5.Caption = "timer"
Form5.WindowState = 2
End Sub
Private Sub start_Click()
Timer1.Enabled = True
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Private Sub stop_Click()


Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Time
Label1.Caption = "no. of records" & c
If (col < 15) Then
Text1.ForeColor = QBColor(col)
col = col + 1 Else
col = 1 End If
If (Text1.Left < 12000 And t = 0) Then
Text1.Top = 100
Text1.Left = Text1.Left + 100
ElseIf (Text1.Left > 9700 And t = 0 And Text1.Top < 9500) Then
Text1.Top = Text1.Top + 100
l=1b=0
ElseIf (Text1.Left >= 1000 And b = 0) Then
Text1.Top = 9400
Text1.Left = Text1.Left - 100
t=1
ElseIf (Text1.Top > 500 And b = 0 And t = 1) Then
Text1.Left = 50
Text1.Top = Text1.Top - 100
Else
c=c+1
t=0b=0l=0
End If End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

12. Program to show the use of menu design.

Design Window

Private Sub abcolorblue_Click()


abcolorblue.Checked = True
abcolorgreen.Checked = False
abcolorred.Checked = False
abcoloryellow.Checked = False
If rectangle.FillStyle = 0 Then
rectangle.FillColor = vbBlue
ElseIf cicle.FillStyle = 0 Then
cicle.FillColor = vbBlue
ElseIf Square.FillStyle = 0 Then
Square.FillColor = vbBlue
End If
End Sub
Private Sub abcolorgreen_Click()
abcolorblue.Checked = False
abcolorgreen.Checked = True
abcolorred.Checked = False
abcoloryellow.Checked = False
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

If rectangle.FillStyle = 0 Then
rectangle.FillColor = vbGreen
ElseIf cicle.FillStyle = 0 Then
cicle.FillColor = vbGreen
ElseIf Square.FillStyle = 0 Then
Square.FillColor = vbGreen
End If
End Sub
Private Sub abcolorred_Click()
abcolorblue.Checked = False
abcolorgreen.Checked = False
abcolorred.Checked = True
abcoloryellow.Checked = False
If rectangle.FillStyle = 0 Then
rectangle.FillColor = vbRed
ElseIf cicle.FillStyle = 0 Then
cicle.FillColor = vbRed
ElseIf Square.FillStyle = 0 Then
Square.FillColor = vbRed
End If
End Sub
Private Sub abcoloryellow_Click()
abcolorblue.Checked = False
abcolorgreen.Checked = False
abcolorred.Checked = False
abcoloryellow.Checked = True
If rectangle.FillStyle = 0 Then
rectangle.FillColor = vbYellow
ElseIf cicle.FillStyle = 0 Then
cicle.FillColor = vbYellow
ElseIf Square.FillStyle = 0 Then
Square.FillColor = vbYellow
End If
End Sub
Private Sub abfileexit_Click()
End
End Sub
Private Sub abshapecircle_Click()
abshapecircle.Checked = True
abshapesquare.Checked = False
abshaperectangle.Checked = False
cicle.FillStyle = 0
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

rectangle.FillStyle = 1
Square.FillStyle = 1
rectangle.FillColor = &H0&
Square.FillColor = &H0&
End Sub
Private Sub abshaperectangle_Click()
abshapecircle.Checked = False
abshapesquare.Checked = False
abshaperectangle.Checked = True
cicle.FillStyle = 1
rectangle.FillStyle = 0
Square.FillStyle = 1
rectangle.FillColor = &H0&
Square.FillColor = &H0&
End Sub
Private Sub abshapesquare_Click()
abshapecircle.Checked = False
abshapesquare.Checked = True
abshaperectangle.Checked = False
cicle.FillStyle = 1
rectangle.FillStyle = 1
Square.FillStyle = 0
rectangle.FillColor = &H0&
Square.FillColor = &H0&
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

13. Program to access data through data control form design.

Design Window

Option Explicit
Dim responce As Integer
Private Sub Command1_Click()
Data1.Recordset.AddNew
Text1.SetFocus
End Sub
Private Sub Command2_Click()
responce = MsgBox("do you want to delete the record", vbYesNo)
If responce = vbYes Then
Data1.Recordset.Delete
Data1.Recordset.MoveFirst
End If
End Sub
Private Sub Command3_Click()
Data1.Recordset.Edit
Data1.Recordset.Update
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Private Sub Command4_Click()


If Data1.Recordset.BOF = True And Data1.Recordset.EOF = True Then
MsgBox "the file is empty"
Else
Data1.Recordset.MoveFirst
End If
End Sub
Private Sub Command5_Click()
If Data1.Recordset.BOF = True And Data1.Recordset.EOF = True Then
MsgBox "the file is empty"
Else
Data1.Recordset.MovePrevious
If Data1.Recordset.BOF = True Then
Data1.Recordset.MoveFirst
MsgBox "you are at 1st record"
End If
End If
End Sub
Private Sub Command6_Click()
If Data1.Recordset.BOF = True And Data1.Recordset.EOF = True Then
MsgBox "the file is empty"
Else
Data1.Recordset.MoveNext
If Data1.Recordset.EOF = True Then
Data1.Recordset.MoveLast
MsgBox " you are at last record"
End If
End If
End Sub
Private Sub Command7_Click()
If Data1.Recordset.BOF = True And Data1.Recordset.EOF = True Then
MsgBox "the file is empty"
Else
Data1.Recordset.MoveLast
End If
End Sub
Private Sub Command8_Click()
End
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

14. Program to draw shape using shape control form design.

Design Window

Private Sub Form_click()


Static currentshape As Integer
Shape1.Shape = currentshape
currentshape = currentshape + 1
cuurentshape = currentshape Mod 6
End Sub
Private Sub form_load()
Dim m$
m$ = "after you click on the ok button to make"
m$ = m$ & "this button go away,each click on the form"
m$ = m$ & "will change the shape of the shape control"
MsgBox m$
End Sub

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

15. Program to draw circle by using method of circle form design.

Design Window

Private Sub Form_Click()


Const pi = 3.14159
Const arcsize = 30
Dim x, y, r As Integer
Dim arcstart As Single, arcend As Single
Dim ncount As Integer
x = Me.ScaleWidth / 2
y = Me.ScaleHeight / 2
r=x/2
Me.DrawMode = vbCopyPen
Me.FillStyle = vbFSTransparent
Me.Circle (x, y), r
'Me.DrawMode = vbXorPen
Me.FillStyle = vbSolid
Me.FillColor = vbGreen
For ncount = 0 To 360
arcstart = ncount
arcend = ncount + arcsize
If arcend > 360 Then arcend = arcend - 360
Me.Caption = "arc of" & arcsize & "degrees starting at" & ncount
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Circle (x, y), r, , -arcstart * pi / 180, -arcend * pi / 180


DoEvents
Circle (x, y), r, , -arcstart * pi / 180, -arcend * pi / 180
Next ncount
Me.Caption = "done"
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

16.Wap to create a file and write /read to /from file through file
handling.

Design Window

Private Sub Command1_Click()


Open "c:\file.txt" For Output As #1
Print #1, Text1.Text
Close #1
End Sub
Private Sub Command2_Click()
Dim a As String
Open "c:\file.txt" For Input As #1
Input #1, a
Text2.Text = a
Close #1
End Sub

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

17.Wap to create a file and write /read to /from file through file handling
using random access concept.

Design Window

Module Coding
Type record
name As String * 50
number As String * 50
End Type
Dim writedata(1 To 50) As record
Dim readdata(1 To 50) As record
Dim totalrecords As Integer
Private Sub Command1_Click()
writedata(1).name = Text1.Text
writedata(1).number = Text2.Text
totalrecords = 1
Open "c:\records.doc" For Random As #1 Len = Len(writedata(1))
For intloopindex = 1 To totalrecords
Put #1, , writedata(intloopindex)
Next intloopindex
Close #1
End Sub
Private Sub Command2_Click()
Dim intloopindex As Integer
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Open "c:\records.doc" For Random As #1 Len = Len(readdata(1))


For intloopindex = 1 To LOF(1) / Len(readdata(1))
Get #1, , readdata(intloopindex)
Next intloopindex
Close #1
Text3.Text = readdata(1).name
Text4.Text = readdata(1).number
End Sub
Private Sub Form_Load()
Command1.Caption = "Write to File"
Command2.Caption = "Read from File"
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

18.Write a program to perform operation in VB through Class Module.

Design Window

Coding of Class Module


Public Function mul(ByVal a As Integer, ByVal b As Integer)
mul = a * b
End Function

Public Function sum(ByVal a As Integer, ByVal b As Integer)


sum = a + b
End Function

Public Function div(ByVal a As Integer, ByVal b As Integer)


div = a / b
End Function

Public Function subt(ByVal a As Integer, ByVal b As Integer)


subt = a - b
End Function
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Dim ac As New Class1


Private Sub Command1_Click()
Dim ab, m1, m2 As Integer
m1 = InputBox("m1")
m2 = InputBox("m2")
ab = ac.mul(m1, m2)
Print ab
MsgBox "result is "("ab")
End Sub

Private Sub Command2_Click()


Dim ab, m1, m2 As Integer
m1 = InputBox("m1")
m2 = InputBox("m2")
ab = ac.sum(m1, m2)
Print ab
MsgBox "result is "("ab")
End Sub

Private Sub Command3_Click()


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Dim ab, m1, m2 As Integer


m1 = InputBox("m1")
m2 = InputBox("m2")
ab = ac.div(m1, m2)
Print ab

MsgBox "result is "("ab")

End Sub

Private Sub Command4_Click()


Dim ab, m1, m2 As Integer
m1 = InputBox("m1")
m2 = InputBox("m2")
ab = ac.subt(m1, m2)
Print ab
MsgBox "result is "("ab")
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351


Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

19. Program to link and embed object in vb through OLE.

Design Window

Private Sub Command1_Click()


With frmole.OLE1
.Height = frmole.oleheight
.Width = frmole.olewidth
End With
If Option1.Value = True Then
frmole.OLE1.SizeMode = 1
Else
frmole.OLE1.SizeMode = 2
End If
If Option3.Value Then
frmole.OLE1.OLETypeAllowed = 1
Else
frmole.OLE1.OLETypeAllowed = 0

End If
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Form1.Hide
frmole.OLE1.InsertObjDlg
If frmole.OLE1.Class <> " " Then
frmole.Command1.Enabled = 2
End If
Unload Form1
End Sub
Private Sub Command2_Click()
Unload frmtype
End Sub
Private Sub Command1_Click()
With frmole.OLE1
.Height = frmole.oleheight
.Width = frmole.olewidth
End With
If Option1.Value = True Then
frmole.OLE1.SizeMode = 1
Else
frmole.OLE1.SizeMode = 2
End If
If Option3.Value Then
frmole.OLE1.OLETypeAllowed = 1
Else
frmole.OLE1.OLETypeAllowed = 0
End If
Form1.Hide
frmole.OLE1.InsertObjDlg
If frmole.OLE1.Class <> " " Then
frmole.Command1.Enabled = 2
End If
Unload Form1
End Sub
Private Sub Command2_Click()
Unload frmtype
End Sub
Option Explicit
Public oleheight As Integer
Public olewidth As Integer
Private Sub Command1_Click()
Form1.Show
End Sub
Private Sub Command3_Click()
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

End
End Sub
Private Sub Form_Load()
oleheight = OLE1.Height
olewidth = OLE1.Width
End Sub
Name: Aadil Hussain

Class: MCA 3rd sem RollNo:16351

Output:

You might also like