martin2k

ForumsVB6GamesSoftwareDirectoryHTMLArticlesBlogContact

Allen OCX


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

ActiveX Control

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.

FExists

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 (*.txt)|*.txt"
CommonDialog1.ShowOpen
If Allen1.FExists(CommonDialog1.FileName) = False Then
MsgBox "The file '" & CommonDialog1.FileName & "' does not exist", vbExclamation, "File Does Not Exist"
Else
'Open file commands
End If

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 at 0.

ColConv

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
Using the ColConv Method

This code is used:

Private Sub List1_Click()
Text1.BackColor = Allen1.ColConv(List1.Text)
End Sub

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):

Private Sub List1_Click()
If List1.Text = "Red" Then Text1.BackColor = 255
End Sub

GetBigIcon

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 image box:

Private Sub Text1_Change()
If Allen1.FExists(Text1.Text) = True Then Image1.Picture = Allen1.GetBigIcon(Text1.Text)
End Sub

When C:\WINDOWS\SYSTEM.INI was typed into the textbox, its icon was displayed in the imagebox:

Using the GetBigIcon Method
Using the GetBigIcon Method

The .GetSmallIcon method would return the file's small icon.

HTML2PT

This function converts simple HTML code to plain text.  I.e.:

  • BR tags are converted into line breaks
  • '&' is converted into '&'
  • '&lt;' and '&gt;' are converted into '<' and '>'
  • '&quot;' is converted into '"'
  • '&nbsp;' is converted into ' '

PT2HTML

This function converts plain text to HTML code.  I.e.:

  • '&' is converted into '&amp;'
  • '<' and '>' are converted into '&lt;' and '&gt;'
  • '"' is converted into '&quot;'
  • Consecutive spaces are converted into a mixture of space characters and '&nbsp;'
  • 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

Private Sub Command1_Click()
Text2.Text = PT2HTML(Text1.Text, True)
End Sub

TopMost

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
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.


blog comments powered by Disqus

Archived Comments

From: imdad
Date: Friday, January 26, 2007 at 19:53:57
Comments: I am thank ful of your website to give me a great example in visual basic programming.
 
From: Rajesh Niar
Date: Saturday, January 6, 2007 at 10:23:49
Comments: Very nice application. Thanks a lot
 
From: Lautaro
Date: Saturday, January 22, 2005 at 00:26:04
Comments: Cool, just what I was looking for! I need it for a process that takes to much time and it's very heavy, and the computer may freeze if youdo sometihng at that time. Thanks!
 
From: Franco Guerra
Date: Wednesday, December 1, 2004 at 11:06:29
Comments: Compliments!!!
I'm Italian Programmers and I download Your OCX for my application. I remarke in my application your name !!
Hi
Francesco
 
From: venkat
Date: Tuesday, November 4, 2003 at 09:54:52
Comments: good

Martin Allen 1999 - 2011.  Last updated Wednesday 10 August 2011 07:19:50 PM +0100.