Pseudo - Splitter Control
- Last updated:Fri, Mar 26, 2010 -

The image on the left is a ToolBox of VB.NET, not a ToolBox of Excel VBA. As you can see there is a built-in splitter control.
Unfortunately VBA does not have a splitter ActiveX control like VB.NET. Can't this control be used in VBA? The answer would be yes.
But we can substitute another control for a splitter control.
Here is a sample how to make an image control using like a splitter control using Mouse events.
Just follow few simple steps -
1. Place two TextBox controls (TextBox1 and TextBox2) on the Userform.
2. Place an Image control (Image1) between above mentioned TextBox controls.
3. Slect Image1 then change the MousePointer property
0 - fmMousePointerDefault to
9 - fmMousePointerSizeWE.
4. Slect Image1 then change the color of the BackColor and BorderColor properties as the
same color of the background color of the Userform.
Download
A sample workbook is available at
sample_081.zip
| downloaded 545 time(s)
Example
Place the following in an Userform module.
Option Explicit
Dim bMoveFlag As Boolean
Private Sub Image1_MouseDown(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
bMoveFlag = True
End Sub
Private Sub Image1_MouseUp(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
bMoveFlag = False
End Sub
Private Sub Image1_MouseMove(ByVal Button As Integer, _
ByVal Shift As Integer, _
ByVal X As Single, _
ByVal Y As Single)
If bMoveFlag = True Then
If Image1.Left + X >= 0 Then
If TextBox1.Width + X >= 0 Then
If TextBox2.Width - X >= 0 Then
With Image1
.Move .Left + X, .Top, .Width, .Height
.Visible = True
End With
With TextBox1
.Width = .Width + X
End With
With TextBox2
.Move .Left + X, .Top, .Width, .Height
.Width = .Width - X
End With
End If
End If
End If
End If
End Sub
|