Monday, June 14, 2010

OLE CONTROL

Buzz It
AIM:To prepare a form for using OLE control
CODE
Form 1
Private Sub OPEN_Click()
Dim fnum As Integer
On Error GoTo cancel
CommonDialog1.ShowOpen
fnum = FreeFile
Open CommonDialog1.FileName For Binary As #fnum
OLE1.ReadFromFile (fnum)
Close #fnum
Exit Sub
cancel:
MsgBox "could not load file"
Close #fnum
End Sub
Private Sub SAVE_Click()
Dim fnum As Integer
On Error GoTo cancel
fnum = FreeFile
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Binary As #fnum
OLE1.SaveToFile (fnum)
Close #fnum
Exit Sub
cancel:
MsgBox "could not save file"
Close #fnum
End Sub
Private Sub EXIT_Click()
End
End Sub

Private Sub mnuExit_Click(Index As Integer)
End
End Sub
Private Sub mnuOPen_Click(Index As Integer)
Dim fnum As Integer
On Error GoTo cancel
CommonDialog1.ShowOpen
fnum = FreeFile
Open CommonDialog1.FileName For Binary As #fnum
OLE1.ReadFromFile (fnum)
Close #fnum
Exit Sub
cancel:
MsgBox "could not load file" + Err.Description
Close #fnum
End Sub
Private Sub mnuSave_Click(Index As Integer)
Dim fnum As Integer
On Error GoTo cancel
fnum = FreeFile
CommonDialog1.ShowSave
Open CommonDialog1.FileName For Binary As #fnum
OLE1.SaveToFile (fnum)
Close #fnum
Exit Sub
cancel:
MsgBox "could not save file"
Close #fnum
End Sub

0 comments:

Post a Comment