You are on page 1of 12

UNIT II

VISUAL BASIC

List out the properties that can be edited by VB menu editor Write in detail about various Debugging Techniques in VB List and explain the properties and methods of grid control. Explain the ActiveX Controls in VB

ActiveX Controls in VB
Building to an OCX binary Building as part of an EXE project (generally recommended) Building either of the above helped by the ActiveX Control Wizard Interface

ActiveX Controls
ActiveX Controls In the Learning Edition of VB there were only 4 ActiveX controls, but in the Professional Edition of VB, Microsoft has provided 20 additional controls. Introduction As with the Intrinsic controls, not all of the ActiveX controls are equally useful. Some you will use on many applications but you will use others only when you have a special need for the features the controls offer. When you start VB, none of the ActiveX controls are displayed in the Toolbox. Only the intrinsic controls are displayed, so you must manually insert the ActiveX controls into the Toolbox as you need them. To do so, right-mouse click on the toolbox and go to "Components", select the controls to put on the toolbox and press "OK".

Here's a picture of the Toolbox with all of the Pro controls loaded.

Building to an OCX binary

Building to an OCX binary


Add a command button to the control, so do that and make sure it's in the very top lefthand corner of the UserControl surface:

Building to an OCX binary


Click event has no parameters MouseDown event hasfour parameters Option Explicit ' HERE ARE SOME EVENTS Event Click() Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Building to an OCX binary


property of button Caption To be able to read and write properties to a control, you have to provide a Get and a Let function.
Property Get Caption() As String Caption = Command1.Caption End Property Property Let Caption(newCap As String) Command1.Caption = newCap End Property

Building to an OCX binary


An example of a couple of these events being used to resize the button to be the size the developer draws the UserControl to and to set the initial caption of the button: ' HERE ARE SOME USERCONTROL HANDLERS Private Sub UserControl_Initialize() Command1.Caption = UserControl.Name End Sub Private Sub UserControl_Resize() Command1.Width = UserControl.Width Command1.Height = UserControl.Height End Sub

in the case of the Click event, no parameters are included except the name of the event that's being fired. In the case of the MouseDown event however, four parameters are supplied . Private Sub Command1_Click() RaiseEvent Click End Sub Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) RaiseEvent MouseDown(Button, Shift, X, Y) End Sub

http://pages.cpsc.ucalgary.ca/~saul/vb_examp les/tutorial10/activex01.html