AllenOCX is an ActiveX control that I made to help myself and
others with common tasks in Visual Basic. It is the first control that I
made. You can read its text file here,
or download it here.
When you are designing a program that will allow the user to open a file, you
will need a way of checking to see if that file exists. Using the
Microsoft Common Dialog Control 6.0 (SP3) as well, you can check to see if a
file exists with this code:
CommonDialog1.Filter = "Text document
If Allen1.FExists(CommonDialog1.FileName) =
MsgBox "The file '" & CommonDialog1.FileName & "'
does not exist", vbExclamation, "File Does Not Exist"
'Open file commands
The .FExists method is used. As you can see, the above code uses If,
Then, Else and End If code so that if the file did not exist, a message box will
be displayed warning the user that the file specified did not exist. There
is a Flag property you can set to stop the Common Dialog control from opening
files that do not exist, but for the above example, the Flag property was left
If you are designing a program that uses a list of colours that the user can
click on to change the colour of another control such as a textbox, the .ColConv
method will be useful. When an item in the listbox is clicked on, code
will be executed to change the background colour of the textbox:
Using the ColConv Method
This code is used:
Text1.BackColor = Allen1.ColConv(List1.Text)
The .ColConv method returns the number associated with that colour, so the
following code will also have created a red background (but code for all colours
would need to be added):
If List1.Text = "Red" Then
Text1.BackColor = 255
The following code is executed when text is typed into a textbox. When
that text is a valid file name, the icon for that file will be displayed in an
If Allen1.FExists(Text1.Text) = True Then
Image1.Picture = Allen1.GetBigIcon(Text1.Text)
When C:\WINDOWS\SYSTEM.INI was typed into the textbox, its icon was displayed
in the imagebox:
Using the GetBigIcon Method
The .GetSmallIcon method would return the file's small icon.
This function converts simple HTML code to plain text. I.e.:
This function converts plain text to HTML code. I.e.:
'&' is converted into '&'
'<' and '>' are converted into '<' and '>'
'"' is converted into '"'
Consecutive spaces are converted into a mixture of space characters and
Tab characters are converted into 4 spaces
BR tags are created if
the CreateBRs argument is set to True in order to create line breaks
Text2.Text = PT2HTML(Text1.Text, True)
There are times when you will want you application to be displayed above all
others even if it is not currently in focus. This is where the .TopMost
method comes in. To get your application to do this:
Using the TopMost Method
The code for this is again, quite simple:
Allen1.TopMost Me, True
'The form is TopMost
Allen1.TopMost Me, False
'The form is no longer TopMost
I hope this page has given you an idea of what the Allen OCX
component can do. Have a look at the other ActiveX pages to see how to use them.