0% found this document useful (0 votes)
4 views

Astuce

The document provides instructions for preventing an application from launching multiple instances, creating an 'About' dialog for ActiveX controls, and opening various Control Panel items through code. It also includes a detailed interface definition for the cPopMenu and vbAcceleratorGrid libraries, outlining their methods, properties, and events. Additionally, it offers code snippets for unloading forms and managing menu items within these controls.

Uploaded by

khalid
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Astuce

The document provides instructions for preventing an application from launching multiple instances, creating an 'About' dialog for ActiveX controls, and opening various Control Panel items through code. It also includes a detailed interface definition for the cPopMenu and vbAcceleratorGrid libraries, outlining their methods, properties, and events. Additionally, it offers code snippets for unloading forms and managing menu items within these controls.

Uploaded by

khalid
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 19

Empêcher que l'application se lance plusieurs fois

Dans la procédure Form_Load (ou MDIForm_Load) de la feuille de démarrage de votre application :


Private Sub Form_Load ' ou MDIForm_Load selon le type de feuille
If App.PrevInstance Then
MsgBox "Programme déjà ouvert", vbOkOnly + vbExclamation, App.Title
Unload Me
End If
End Sub

Boîte de dialogue A propos pour un contrôle ActiveX


Vous avez sans doute remarqué que beaucoup de contrôles ActiveX possèdent une rubrique "(A propos)" dans la
boîte de propriétés ?
Mais comment faire pour faire la même chose ?
C'est très simple :
1. Ajoutez une Form à votre projet de contrôle ActiveX, que vous nommerez FrmAbout
2. Personnalisez cette feuille comme vous le voulez
3. Créez une procédure privée nommée ShowAbout avec une seule instruction : FrmAbout.Show vbModal
4. Sélectionnez votre procédure
5. Cliquez sur le menu Options
6. Puis sur le sous-menu Attributs de procédure
7. Dans la boîte de dialogue ouverte, tapez Affiche la boîte de dialogue A propos de comme description
8. Cliquez sur le bouton Avancés >>
9. Prenez AboutBox comme ID de procédure
Voilà !

Ouvrir un élément du panneau de configuration


Dans une procédure :
shell "rundll32.exe shell32.dll,Control_RunDLL " + ELEMENT

Valeur de ELEMENT :
- "appwiz.cpl" ' ajout/supression de programmes
- "desk.cpl" ' affichage
- "inetcpl.cpl @0" ' internet
- "inetcpl.cpl @1" ' utilisateurs
- "intl.cpl" ' paramètres régionaux
- "joy.cpl" ' contrôleurs de jeux
- "main.cpl @0" ' souris
- "main.cpl @1" ' clavier
- "modem.cpl" ' modems
- "mmsys.cpl @0" ' multimédia
- "mmsys.cpl @1" ' sons
- "netcpl.cpl" ' réseau
- "password.cpl" ' mots de passe
- "sysdm.cpl @0" ' système
- "sysdm.cpl @1" ' ajout de nouveau matériel
- "timedate.cpl" ' date/heure
Décharger toutes les Forms
Créez la procédure suivante :
Public Sub UnloadAllForms()
Dim Feuille As Form
For Each Feuille In Forms
Unload Feuille
Set Feuille = Nothing
Next Feuille
End Sub

Il vous suffit d'appeler UnloadAllForms pour décharger toutes vos feuilles


Remarque : on peut aussi écrire simplement End

cPopMenu Interface Definition


General Information
Library: cPopMenu (vbAccelerator PopMenu Control - Creates Multilevel Menus with Icons)
File: C:\Stevemac\VB\Controls\cIcoMenu\Release\cPopMenu.ocx
GUID: {A22D979F-2684-11D2-8E21-10B404C10000}
Version: 1.4

Enumerations
This section lists enumerations exposed by cPopMenu.

Public Enum CSPHighlightStyleConstants


cspHighlightStandard=0
cspHighlightButton=1
End Enum
Public Enum CSPPMENUSysCommandConstants
SC_RESTORE=61728
SC_MOVE=61456
SC_SIZE=61440
SC_MAXIMIZE=61488
SC_MINIMIZE=61472
SC_CLOSE=61536
SC_ARRANGE=61712
SC_HOTKEY=61776
SC_HSCROLL=61568
SC_KEYMENU=61696
SC_MANAGER_CONNECT=1
SC_MANAGER_CREATE_SERVICE=2
SC_MANAGER_ENUMERATE_SERVICE=4
SC_MANAGER_LOCK=8
SC_MANAGER_MODIFY_BOOT_CONFIG=32
SC_MANAGER_QUERY_LOCK_STATUS=16
SC_MOUSEMENU=61584
SC_NEXTWINDOW=61504
SC_PREVWINDOW=61520
SC_SCREENSAVE=61760
SC_TASKLIST=61744
SC_VSCROLL=61552
SC_ZOOM=61488
SC_ICON=61472
End Enum
Public Enum CSPShowPopupMenuConstants
TPM_CENTERALIGN=4
TPM_LEFTALIGN=0
TPM_LEFTBUTTON=0
TPM_RIGHTALIGN=8
TPM_RIGHTBUTTON=2
TPM_HORIZONTAL=0
TPM_VERTICAL=64
TPM_RECURSE=1
TPM_HORPOSANIMATION=1024
TPM_HORNEGANIMATION=2048
TPM_VERPOSANIMATION=4096
TPM_VERNEGANIMATION=8192
TPM_NOANIMATION=16384
End Enum

Interfaces
This section lists the Classes exposed by cPopMenu. For each class, the methods and events are listed.

PopMenu {A22D979C-2684-11D2-8E21-10B404C10000}

Methods
Property Get HighlightStyle() As CSPHighlightStyleConstants
Under development.
Property Let HighlightStyle(RHS As CSPHighlightStyleConstants)
Under development.
Function ShowPopupMenu(ByVal objTo As Object, ByVal vKeyParent As Variant, ByVal x As
Single, ByVal y As Single, Optional ByVal eOptions As CSPShowPopupMenuConstants=0) As
Long
Shows the popup menu associated with a given menu item.
Property Set BackgroundPicture() As Picture
Sets a picture to tile into the background of the menu.
Property Get BackgroundPicture() As Picture
Sets a picture to tile into the background of the menu.
Sub ClearBackgroundPicture
Removes the picture set with the BackgroundPicture property.
Sub GetVersion(ByVal lMajor As Long, ByVal lMinor As Long, ByVal lRevision As Long)
Returns the current control version string.
Property Get HighlightCheckedItems() As Boolean
Gets/sets whether the background to icons for checked menu items are highlighted using a dither pattern
when the menu item is selected.
Property Let HighlightCheckedItems(RHS As Boolean)
Gets/sets whether the background to icons for checked menu items are highlighted using a dither pattern
when the menu item is selected.
Property Get MenuExists(ByVal vKey As Variant) As Boolean
Returns whether a given menu index or key exists in the menu.
Property Get MenuIndex(ByVal vKey As Variant) As Long
Gets the index of the menu item with the specified key.
Property Get MenuKey(ByVal lIndex As Long) As String
Gets/sets a unique key string associated with a menu item.
Property Let MenuKey(ByVal lIndex As Long, RHS As String)
Gets/sets a unique key string associated with a menu item.
Property Get MenuTag(ByVal vKey As Variant) As String
Gets/sets a string value associated with a menu item.
Property Let MenuTag(ByVal vKey As Variant, RHS As String)
Gets/sets a string value associated with a menu item.
Property Get MenuDefault(ByVal vKey As Variant) As Boolean
Gets/sets whether the menu item should be shown in Bold font.
Property Let MenuDefault(ByVal vKey As Variant, RHS As Boolean)
Gets/sets whether the menu item should be shown in Bold font.
Property Let TickIconIndex(RHS As Long)
Gets/sets the 0 based index of an icon in the ImageList used to draw the check image for checked menu
items if no other icon has been set.
Property Get TickIconIndex() As Long
Gets/sets the 0 based index of an icon in the ImageList used to draw the check image for checked menu
items if no other icon has been set.
Property Get SystemMenuCaption(ByVal lPosition As Long) As String
Gets/sets the caption of a system menu item given its ID.
Property Get SystemMenuCount() As Long
Returns the number of items on the system menu.
Sub SystemMenuRemoveItem(ByVal lPosition As Long)
Removes an item from the system menu given its ID.
Function SystemMenuAppendItem(ByVal sCaption As String) As Long
Appends an item to the System Menu and returns its identifier ID.
Sub SystemMenuRestore
Restores the system menu to its default state.
Property Let ImageList(RHS As Variant)
Associates an ImageList with the control. This can either be a COMCTL32 image list, a vbAccelerator
ImageList or an API hImageList handle. Make sure the ImageList contains some icons before using this.
Property Get Caption(ByVal vKey As Variant) As String
Gets/sets the caption of a menu item.
Property Let Caption(ByVal vKey As Variant, RHS As String)
Gets/sets the caption of a menu item.
Property Get Enabled(ByVal vKey As Variant) As Boolean
Gets/sets whether a menu item appears enabled or not.
Property Let Enabled(ByVal vKey As Variant, RHS As Boolean)
Gets/sets whether a menu item appears enabled or not.
Property Get Checked(ByVal vKey As Variant) As Boolean
Gets/sets whether a menu item is checked or not.
Property Let Checked(ByVal vKey As Variant, RHS As Boolean)
Gets/sets whether a menu item is checked or not.
Property Get HelpText(ByVal vKey As Variant) As String
Gets/sets a string associated with a menu item. This can be used to display help text in response to the
MenuHighlight event.
Property Let HelpText(ByVal vKey As Variant, RHS As String)
Gets/sets a string associated with a menu item. This can be used to display help text in response to the
MenuHighlight event.
Property Let ItemIcon(ByVal vKey As Variant, RHS As Long)
Gets/sets the 0 based index of an icon in the ImageList to be shown against a menu item. Set to -1 to
show no icon.
Property Get ItemIcon(ByVal vKey As Variant) As Long
Gets/sets the 0 based index of an icon in the ImageList to be shown against a menu item. Set to -1 to
show no icon.
Property Get ItemData(ByVal vKey As Variant) As Long
Gets/sets a long value associated with a menu item.
Property Let ItemData(ByVal vKey As Variant, RHS As Long)
Gets/sets a long value associated with a menu item.
Property Get hPopupMenu(ByVal vKey As Variant) As Long
Returns a Win32 hMenu handle to a popup menu under the specified menu item.
Property Get PositionInMenu(ByVal vKey As Variant) As Long
Under development.
Property Get NextSibling(ByVal vKey As Variant) As Long
Gets the next menu item from the specified menu item.
Property Get SiblingCount(ByVal vKey As Variant) As Long
Returns the number of menu items at the same level as the specified menu item.
Property Get HasChildren(ByVal vKey As Variant) As Variant
Returns whether the specified menu item has any sub-menus.
Property Get FirstChild(ByVal vKey As Variant) As Long
Returns the index of the first menu item below the specified item.
Property Get Parent(ByVal vKey As Variant) As Long
Gets the index of the parent menu item for a given menu item.
Property Get UltimateParent(ByVal vKey As Variant) As Long
Gets the ultimate parent menu item index of a given menu item.
Property Get IndexForMenuHierarchyParamArray(Optional ByVal vHierarchy() As Variant) As
Long
Same as IndexForMenuHierarchy, but takes a parameter array rather than a long array type as the
hierarchy.
Property Get IndexForMenuHierarchy(ByVal lHierarchy() As Long) As Long
Returns the index for the menu item which appears at the given hierarchy.
Sub GetHierarchyForIndexPosition(ByVal vKey As Variant, ByVal lHierarchy() As Long)
Returns a hierarchy for a given menu index. The hierarchy is an array indicating the position of the menu
at each level.
Property Get HierarchyPath(ByVal vKey As Variant, ByVal lStartLevel As Long, ByVal sSeparator
As String) As String
Returns a string containing a path equivalent of a given menu item. For example, this might be
FavouritesSites.
Function ClearSubMenusOfItem(ByVal vKey As Variant) As Long
Removes all sub menus of a particular menu item.
Sub RemoveItem(ByVal vKey As Variant)
Removes a given menu item.
Property Get IDForIndex(ByVal vKey As Variant) As Long
Returns the Win32 Menu Identifier for a given menu item.
Function AddItem(ByVal sCaption As String, Optional ByVal sKey As String=, Optional ByVal
sHelptext As String=, Optional ByVal lItemData As Long=0, Optional ByVal lParentIndex As
Long=0, Optional ByVal lIconIndex As Long=-1, Optional ByVal bChecked As Boolean=False,
Optional ByVal bEnabled As Boolean=True) As Long
Adds a new menu item and optionally sets extended properties.
Function ReplaceItem(ByVal vKey As Variant, Optional ByVal sCaption As Variant, Optional ByVal
sHelptext As Variant, Optional ByVal lItemData As Variant, Optional ByVal lIconIndex As Variant,
Optional ByVal bChecked As Variant, Optional ByVal bEnabled As Variant) As Long
Replaces a menu item with the specified properties.
Function InsertItem(ByVal sCaption As String, ByVal vKeyBefore As Variant, Optional ByVal sKey
As String=, Optional ByVal sHelptext As String=, Optional ByVal lItemData As Long=0, Optional
ByVal lIconIndex As Long=-1, Optional ByVal bChecked As Boolean=False, Optional ByVal
bEnabled As Boolean=True) As Long
Same as the AddItem method, except the menu item is inserted before the specified menu item.
Sub EnsureMenuSeparators(ByVal hMenu As Long)
Under development.
Sub Clear
Removes all menus.
Property Get Count() As Integer
Gets the total number of menu items.
Sub SubClassMenu(Optional ByVal oForm As Object=Nothing, Optional ByVal
bLeaveTopLevelMenus As Boolean=False)
Initialises the icon menu against a form's menu. Call this method before using any other methods except
ImageList.
Sub CheckForNewItems
Interogates the menu and checks for any new items or removed items (i.e. ones which have been
Loaded, Unloaded or had their Visible property changed). For each new item found, the
RequestNewMenuDetails event is raised.
Property Get MenuItemsPerScreen() As Long
Returns the number of menu items which can be fitted vertically on the screen.
Sub UnsubclassMenu
Under development.
Events

Public Event Click(ByVal ItemNumber As Long)


Raised when a non-VB menu item(i.e. one added using this control) is clicked.
Public Event SystemMenuClick(ByVal ItemNumber As Long)
Raised when a system menu item is clicked.
Public Event ItemHighlight(ByVal ItemNumber As Long, ByVal bEnabled As Boolean, ByVal
bSeparator As Boolean)
Raised when a menu item is highlighted.
Public Event SystemMenuItemHighlight(ByVal ItemNumber As Long, ByVal bEnabled As Boolean,
ByVal bSeparator As Boolean)
Raised when a system menu item is highlighted.
Public Event MenuExit
Raised when the user exits from a menu.
Public Event InitPopupMenu(ByVal ParentItemNumber As Long)
Raised just before a popup menu is about to be shown. You can modify the items in this menu at this
point.
Public Event WinIniChange
Raised when system settings are changed.
Public Event NewMDIMenu
Raised in an MDI project where child forms have their own menus. When the child is shown, the control
will detect the change in menu and raise this event.
Public Event RequestNewMenuDetails(ByVal sCaption As String, ByVal sKey As String, ByVal
iIcon As Long, ByVal lItemData As Long, ByVal sHelptext As String, ByVal sTag As String)
Raised if the control finds a new menu item after the CheckForNewMenuItems method has been called.

vbAcceleratorGrid Interface Definition


General Information
Library: vbAcceleratorGrid (vbAccelerator Grid Control)
File: C:\Stevemac\VB\Controls\S-Grid4\Release\vbalGrid.ocx
GUID: {017E002E-D7CC-11D2-8E21-44B10AC10000}
Version: 15.0

Enumerations
This section lists enumerations exposed by vbAcceleratorGrid.

Public Enum cShellSortOrderCOnstants


CCLOrderNone=0
CCLOrderAscending=1
CCLOrderDescending=2
End Enum
Public Enum cShellSortTypeConstants
CCLSortNumeric=100
CCLSortString=102
CCLSortDate=200
CCLSortDateYearAccuracy=250
CCLSortDateMonthAccuracy=251
CCLSortDateDayAccuracy=252
CCLSortDateHourAccuracy=253
CCLSortDateMinuteAccuracy=254
CCLSortIcon=300
CCLSortExtraIcon=301
CCLSortForeColor=400
CCLSortBackColor=401
CCLSortFontIndex=500
CCLSortSelected=600
CCLSortIndentation=700
End Enum
Public Enum ECGBorderStyle
ecgBorderStyleNone=0
ecgBorderStyle3d=1
ecgBorderStyle3dThin=2
End Enum
Public Enum ECGHdrTextAlignFlags
ecgHdrTextALignLeft=0
ecgHdrTextALignCentre=2
ecgHdrTextALignRight=1
End Enum
Public Enum ECGScrollBarStyles
ecgSbrRegular=0
ecgSbrEncarta=1
ecgSbrFlat=2
End Enum
Public Enum ECGSerialiseTypes
ecgSerialiseSGRID=0
ecgSerialiseSGRIDLayout=1
ecgSerialiseTextTabNewLine=2
ecgSerialiseCSV=3
End Enum
Public Enum ECGTextAlignFlags
DT_TOP=0
DT_LEFT=0
DT_CENTER=1
DT_RIGHT=2
DT_VCENTER=4
DT_BOTTOM=8
DT_WORDBREAK=16
DT_SINGLELINE=32
DT_EXPANDTABS=64
DT_TABSTOP=128
DT_NOCLIP=256
DT_EXTERNALLEADING=512
DT_CALCRECT=1024
DT_NOPREFIX=2048
DT_INTERNAL=4096
DT_EDITCONTROL=8192
DT_PATH_ELLIPSIS=16384
DT_END_ELLIPSIS=32768
DT_MODIFYSTRING=65536
DT_RTLREADING=131072
DT_WORD_ELLIPSIS=262144
End Enum

Interfaces
This section lists the Classes exposed by vbAcceleratorGrid. For each class, the methods and events are
listed.

cGridCell {C47CB531-DA3E-11D2-8E21-44C10AC10000}

Methods
Property Get ItemData() As Long

Property Let ItemData(RHS As Long)

Property Get TextAlign() As ECGTextAlignFlags

Property Let TextAlign(RHS As ECGTextAlignFlags)

Property Get Text() As Variant

Property Let Text(RHS As Variant)

Property Get Font() As Font

Property Set Font() As Font

Property Get IconIndex() As Long

Property Let IconIndex(RHS As Long)

Property Get ExtraIconIndex() As Long

Property Let ExtraIconIndex(RHS As Long)

Property Get Indent() As Long


Property Let Indent(RHS As Long)

Property Get BackColor() As ULong

Property Let BackColor(RHS As ULong)

Sub DefaultBackColor

Property Get ForeColor() As ULong

Property Let ForeColor(RHS As ULong)

Sub DefaultForeColor

Events
None

cShellSortTGridCells {C47CB525-DA3E-11D2-8E21-44C10AC10000}

Methods
Sub Clear
Clears all sort settings.
Property Get LastSortIndex() As Integer

Property Let LastSortIndex(RHS As Integer)

Property Let SortColumn(ByVal iSortIndex As Integer, RHS As Integer)


Gets/sets the grid column to sort by. Up to three grid columns can be specified for a sort.
Property Get SortColumn(ByVal iSortIndex As Integer) As Integer
Gets/sets the grid column to sort by. Up to three grid columns can be specified for a sort.
Property Let SortOrder(ByVal iSortIndex As Integer, RHS As cShellSortOrderCOnstants)
Gets/sets the order to sort in for a specified sort column. Up to three columns can be specified for a sort.
Property Get SortOrder(ByVal iSortIndex As Integer) As cShellSortOrderCOnstants
Gets/sets the order to sort in for a specified sort column. Up to three columns can be specified for a sort.
Property Get SortType(ByVal iSortIndex As Integer) As cShellSortTypeConstants
Gets/sets the type of sorting to use for a specified sort column. Up to three columns can be specified for
a sort.
Property Let SortType(ByVal iSortIndex As Integer, RHS As cShellSortTypeConstants)
Gets/sets the type of sorting to use for a specified sort column. Up to three columns can be specified for
a sort.
Events
None

vbalGrid {C47CB52A-DA3E-11D2-8E21-44C10AC10000}

Methods
Property Get HighlightSelectedIcons() As Boolean
Gets/sets whether icons in selected cells will be highlighted using the selection colour.
Property Let HighlightSelectedIcons(RHS As Boolean)
Gets/sets whether icons in selected cells will be highlighted using the selection colour.
Property Get DrawFocusRectangle() As Boolean
Gets/sets whether a focus rectangle (dotted line around the selection) will be shown.
Property Let DrawFocusRectangle(RHS As Boolean)
Gets/sets whether a focus rectangle (dotted line around the selection) will be shown.
Property Get Enabled() As Boolean
Gets/sets whether the grid is enabled or not. Note the grid can still be read when it is disabled, but
cannot be selected or edited.
Property Let Enabled(RHS As Boolean)
Gets/sets whether the grid is enabled or not. Note the grid can still be read when it is disabled, but
cannot be selected or edited.
Property Get DisableIcons() As Boolean
Gets/sets whether icons are drawn disabled when the control is disabled.
Property Let DisableIcons(RHS As Boolean)
Gets/sets whether icons are drawn disabled when the control is disabled.
Property Get Editable() As Boolean
Gets/sets whether the grid will be editable (i.e. raise RequestEdit events).
Property Let Editable(RHS As Boolean)
Gets/sets whether the grid will be editable (i.e. raise RequestEdit events).
Property Get SortObject() As cShellSortTGridCells
Returns a reference to the sort object where grid sorting options can be specified.
Sub Sort
Sorts the grid data according to the options set up in the SortObject.
Property Get EvaluateTextHeight(ByVal lRow As Long, ByVal lCol As Long) As Long
Determines the ideal height required to display all the cell's text in a cell. This property is only of any use
if the Cell's CellTextAlign property allows multiple lines.
Property Get EvaluateTextWidth(ByVal lRow As Long, ByVal lCol As Long, Optional ByVal
bForceNoModify As Boolean=True) As Long
Determines the ideal width required to fully display text in a cell.
Property Let DefaultRowHeight(RHS As Long)
Gets/sets the height which will be used as a default for rows in the grid.
Property Get DefaultRowHeight() As Long
Gets/sets the height which will be used as a default for rows in the grid.
Property Get Redraw() As Boolean
Gets/sets whether the grid is redrawn in response to changes. Set to False whilst setting many properties
to increase speed. Setting to True after it has been False forces a re-draw of the control.
Property Let Redraw(RHS As Boolean)
Gets/sets whether the grid is redrawn in response to changes. Set to False whilst setting many properties
to increase speed. Setting to True after it has been False forces a re-draw of the control.
Property Let ScrollBarStyle(RHS As ECGScrollBarStyles)
Gets/sets the style in which scroll bars are drawn. Flat or Encarta style scroll bars are only supported in
systems with COMCTL32.DLL version 4.72 or higher.
Property Get ScrollBarStyle() As ECGScrollBarStyles
Gets/sets the style in which scroll bars are drawn. Flat or Encarta style scroll bars are only supported in
systems with COMCTL32.DLL version 4.72 or higher.
Property Get CellFormattedText(ByVal lRow As Long, ByVal lCol As Long) As String
Gets the text of a cell with any formatting string applicable to the cell's column applied.
Property Get CellText(ByVal lRow As Long, ByVal lCol As Long) As Variant
Gets/sets the text associated with a cell. This property is a variant allowing you to store Numbers and
Dates as well. In columns which are not visible, it could also be used to store objects.
Property Let CellText(ByVal lRow As Long, ByVal lCol As Long, RHS As Variant)
Gets/sets the text associated with a cell. This property is a variant allowing you to store Numbers and
Dates as well. In columns which are not visible, it could also be used to store objects.
Property Get CellTextAlign(ByVal lRow As Long, ByVal lCol As Long) As ECGTextAlignFlags
Gets/sets the alignment and formatting properties used to draw cell text.
Property Let CellTextAlign(ByVal lRow As Long, ByVal lCol As Long, RHS As ECGTextAlignFlags)
Gets/sets the alignment and formatting properties used to draw cell text.
Property Get CellIndent(ByVal lRow As Long, ByVal lCol As Long) As Long
Gets/sets the horizontal indentation of a cell from the cell's border.
Property Let CellIndent(ByVal lRow As Long, ByVal lCol As Long, RHS As Long)
Gets/sets the horizontal indentation of a cell from the cell's border.
Property Get CellExtraIcon(ByVal lRow As Long, ByVal lCol As Long) As Long
Gets/sets the extra icon for a cell. This icon will always appear in the leftmost position for the cell. Set
CellExtraIcon to -1 to remove an icon. CellExtraIcons represent ImageList icon indexes and run from 0 to
Count-1.
Property Let CellExtraIcon(ByVal lRow As Long, ByVal lCol As Long, RHS As Long)
Gets/sets the extra icon for a cell. This icon will always appear in the leftmost position for the cell. Set
CellExtraIcon to -1 to remove an icon. CellExtraIcons represent ImageList icon indexes and run from 0 to
Count-1.
Property Get CellItemData(ByVal lRow As Long, ByVal lCol As Long) As Long
Gets/sets a long value associated with the cell.
Property Let CellItemData(ByVal lRow As Long, ByVal lCol As Long, RHS As Long)
Gets/sets a long value associated with the cell.
Property Get CellSelected(ByVal lRow As Long, ByVal lCol As Long) As Boolean
Gets/sets whether a cell is selected or not.
Property Let CellSelected(ByVal lRow As Long, ByVal lCol As Long, RHS As Boolean)
Gets/sets whether a cell is selected or not.
Property Get CellIcon(ByVal lRow As Long, ByVal lCol As Long) As Long
Gets/sets the icon for a cell. If the cell has an icon set via the CellExtraIcon property, this icon will appear
after it. Set CellIcon to -1 to remove an icon. CellIcons represent ImageList icon indexes and run from 0
to Count-1.
Property Let CellIcon(ByVal lRow As Long, ByVal lCol As Long, RHS As Long)
Gets/sets the icon for a cell. If the cell has an icon set via the CellExtraIcon property, this icon will appear
after it. Set CellIcon to -1 to remove an icon. CellIcons represent ImageList icon indexes and run from 0
to Count-1.
Property Get CellBackColor(ByVal lRow As Long, ByVal lCol As Long) As ULong
Gets/sets the background colour for a cell. Set to -1 to make the cell transparent.
Property Let CellBackColor(ByVal lRow As Long, ByVal lCol As Long, RHS As ULong)
Gets/sets the background colour for a cell. Set to -1 to make the cell transparent.
Property Get CellForeColor(ByVal lRow As Long, ByVal lCol As Long) As ULong
Gets/sets the foreground colour to draw a cell in. Set to -1 to use the default foreground colour.
Property Let CellForeColor(ByVal lRow As Long, ByVal lCol As Long, RHS As ULong)
Gets/sets the foreground colour to draw a cell in. Set to -1 to use the default foreground colour.
Sub CellDefaultForeColor(ByVal lRow As Long, ByVal lCol As Long)
Sets a cell to use the default foreground colour (the fore colour of the control).
Sub CellDefaultBackColor(ByVal lRow As Long, ByVal lCol As Long)
Sets a cell to use the default background colour (transparent).
Property Get CellFont(ByVal lRow As Long, ByVal lCol As Long) As Font
Gets/sets the font to use to draw a cell.
Property Let CellFont(ByVal lRow As Long, ByVal lCol As Long, RHS As Font)
Gets/sets the font to use to draw a cell.
Sub CellDefaultFont(ByVal lRow As Long, ByVal lCol As Long)
Sets a cell to use the default font.
Property Get MultiSelect() As Boolean
Gets/sets whether multiple grid cells or rows can be selected or not.
Property Let MultiSelect(RHS As Boolean)
Gets/sets whether multiple grid cells or rows can be selected or not.
Property Get RowMode() As Boolean
Gets/sets whether cells can be selected in the grid (False) or rows (True).
Property Let RowMode(RHS As Boolean)
Gets/sets whether cells can be selected in the grid (False) or rows (True).
Property Get RowIsGroup(ByVal lRow As Long) As Boolean
Gets/sets whether a row should be regarded as a group row.
Property Let RowIsGroup(ByVal lRow As Long, RHS As Boolean)
Gets/sets whether a row should be regarded as a group row.
Property Get RowGroupStartColumn(ByVal lRow As Long) As Long

Property Let RowGroupStartColumn(ByVal lRow As Long, RHS As Long)

Property Get GridLines() As Boolean


Gets/sets whether grid-lines are drawn or not.
Property Let GridLines(RHS As Boolean)
Gets/sets whether grid-lines are drawn or not.
Property Let ImageList(RHS As Variant)
Sets an ImageList as the source of icons for the control. The ImageList can be either a VB ImageList, a
vbAccelerator ImageList or an API hIml handle. If it is a VB Image List, the Image List must have had at
least one icon in it before using this prop
Property Set BackgroundPicture() As Picture
Gets/sets a picture to be used as the grid's background.
Property Get BackgroundPicture() As Picture
Gets/sets a picture to be used as the grid's background.
Property Get BackColor() As ULong
Gets/sets the background color of the grid.
Property Let BackColor(RHS As ULong)
Gets/sets the background color of the grid.
Property Get ForeColor() As ULong
Gets/sets the foreground color used to draw the control.
Property Let ForeColor(RHS As ULong)
Gets/sets the foreground color used to draw the control.
Property Get GridLineColor() As ULong
Gets/sets the colour used to draw grid lines.
Property Let GridLineColor(RHS As ULong)
Gets/sets the colour used to draw grid lines.
Property Get Font() As Font
Gets/sets the font used by the control.
Property Set Font() As Font
Gets/sets the font used by the control.
Property Get Virtual() As Boolean
Gets/sets whether the grid is in Virtual Mode (i.e. rows are added as required via the RequestRow and
RequestRowData events).
Property Let Virtual(RHS As Boolean)
Gets/sets whether the grid is in Virtual Mode (i.e. rows are added as required via the RequestRow and
RequestRowData events).
Sub Draw
Draws the control.
Sub CellFromPoint(ByVal xPixels As Long, ByVal yPixels As Long, ByVal lRow As Long, ByVal
lCol As Long)
Gets the cell which contains the given X,Y coordinates (relative to the grid) in pixels.
Sub CellBoundary(ByVal lRow As Long, ByVal lCol As Long, ByVal lLeft As Long, ByVal lTop As
Long, ByVal lWidth As Long, ByVal lHeight As Long)
Gets the co-ordinates of the bounding rectangle for a cell in the grid, in twips.
Function AddColumn(ByVal vKey As String, ByVal sHeader As String, ByVal eAlign As
ECGHdrTextAlignFlags, Optional ByVal iIconIndex As Long=-1, Optional ByVal lColumnWidth As
Long=-1, Optional ByVal bVisible As Boolean=True, Optional ByVal bFixed As Boolean=False,
ByVal vKeyBefore As Variant, Optional ByVal bIncludeInSelect As Boolean=True, ByVal
sFmtString As String, Optional ByVal bRowTextColumn As Boolean=False, Optional ByVal
eSortType As cShellSortTypeConstants=102) As Long
Adds or inserts a column to the grid.
Sub RemoveColumn(ByVal vKey As Variant)
Permanently removes a column from the grid. If all columns are removed, the grid will be cleared. If you
want to temporarily remove a column, use the ColumnVisible property.
Sub SetHeaders
Populates the headers in the control based on the columns in the grid. Called automatically by the control
when Headers is set to True.
Property Get ColumnIndex(ByVal vKey As Variant) As Variant
Gets the index of a column with the specified key.
Property Get ColumnImage(ByVal vKey As Variant) As Long
Gets/sets the image index to show in a column's header. Image indexes are 0 based indexes of the
images in an ImageList.
Property Let ColumnImage(ByVal vKey As Variant, RHS As Long)
Gets/sets the image index to show in a column's header. Image indexes are 0 based indexes of the
images in an ImageList.
Property Get ColumnImageOnRight(ByVal vKey As Variant) As Boolean
Gets/sets whether images (if any) will be shown on the right or not in a column header.
Property Let ColumnImageOnRight(ByVal vKey As Variant, RHS As Boolean)
Gets/sets whether images (if any) will be shown on the right or not in a column header.
Property Get ColumnAlign(ByVal vKey As Variant) As ECGHdrTextAlignFlags
Gets/sets the alignment used to draw the column header for a column.
Property Let ColumnAlign(ByVal vKey As Variant, RHS As ECGHdrTextAlignFlags)
Gets/sets the alignment used to draw the column header for a column.
Property Get ColumnKey(ByVal lCol As Long) As String
Gets/sets the key for column.
Property Let ColumnKey(ByVal lCol As Long, RHS As String)
Gets/sets the key for column.
Property Get ColumnTag(ByVal lCol As Long) As String
Gets/sets a tag string associated with a column in the grid.
Property Let ColumnTag(ByVal lCol As Long, RHS As String)
Gets/sets a tag string associated with a column in the grid.
Property Get Header() As Boolean
Gets/sets whether the grid has a header or not.
Property Let Header(RHS As Boolean)
Gets/sets whether the grid has a header or not.
Property Get HeaderDragReOrderColumns() As Boolean
Gets/sets whether the grid's header columns can be dragged around to reorder them.
Property Let HeaderDragReOrderColumns(RHS As Boolean)
Gets/sets whether the grid's header columns can be dragged around to reorder them.
Property Get HeaderButtons() As Boolean
Gets/sets whether the grid's header has clickable buttons or not.
Property Let HeaderButtons(RHS As Boolean)
Gets/sets whether the grid's header has clickable buttons or not.
Property Get HeaderHotTrack() As Boolean
Gets/sets whether the grid's header tracks mouse movements and highlights the header column the
mouse is over or not.
Property Let HeaderHotTrack(RHS As Boolean)
Gets/sets whether the grid's header tracks mouse movements and highlights the header column the
mouse is over or not.
Sub CellDetails(ByVal lRow As Long, ByVal lCol As Long, ByVal sText As Variant, Optional ByVal
eTextAlign As ECGTextAlignFlags=262176, Optional ByVal lIconIndex As Long=-1, Optional ByVal
oBackColor As ULong=-1, Optional ByVal oForeColor As ULong=-1, Optional ByVal oFont As
Font=Nothing, Optional ByVal lIndent As Long=0, Optional ByVal lExtraIconIndex As Long=-1,
Optional ByVal lItemData As Long=0)
Sets multiple format details for a cell at the same time. Quicker than calling the properties individually.
Property Get Cell(ByVal lRow As Long, ByVal lCol As Long) As cGridCell

Property Let Cell(ByVal lRow As Long, ByVal lCol As Long, RHS As cGridCell)

Property Get NewCellFormatObject() As cGridCell

Property Get RowHeight(ByVal lRow As Long) As Long


Gets/sets the height of a row in the grid.
Property Let RowHeight(ByVal lRow As Long, RHS As Long)
Gets/sets the height of a row in the grid.
Property Get ColumnOrder(ByVal vKey As Variant) As Long
Gets/sets the order of a column in the control.
Property Let ColumnOrder(ByVal vKey As Variant, RHS As Long)
Gets/sets the order of a column in the control.
Property Get ColumnSortType(ByVal vKey As Variant) As cShellSortTypeConstants
Gets/sets a variable which you can use to store the current column sort type.
Property Let ColumnSortType(ByVal vKey As Variant, RHS As cShellSortTypeConstants)
Gets/sets a variable which you can use to store the current column sort type.
Property Get ColumnSortOrder(ByVal vKey As Variant) As cShellSortOrderCOnstants
Gets/sets a variable which you can use to store the current column sort order.
Property Let ColumnSortOrder(ByVal vKey As Variant, RHS As cShellSortOrderCOnstants)
Gets/sets a variable which you can use to store the current column sort order.
Property Get ColumnWidth(ByVal vKey As Variant) As Long
Gets/sets the width of a column in the grid.
Property Let ColumnWidth(ByVal vKey As Variant, RHS As Long)
Gets/sets the width of a column in the grid.
Property Get ColumnHeader(ByVal vKey As Variant) As String
Gets/sets the text to appear in a column header.
Property Let ColumnHeader(ByVal vKey As Variant, RHS As String)
Gets/sets the text to appear in a column header.
Property Get ColumnFormatString(ByVal vKey As Variant) As String
Gets/sets a format string used to format all text in the column. Format strings are the same as those used
in the VB Format$ function.
Property Let ColumnFormatString(ByVal vKey As Variant, RHS As String)
Gets/sets a format string used to format all text in the column. Format strings are the same as those used
in the VB Format$ function.
Property Get ColumnVisible(ByVal vKey As Variant) As Boolean
Gets/sets whether a column will be visible or not in the grid.
Property Let ColumnVisible(ByVal vKey As Variant, RHS As Boolean)
Gets/sets whether a column will be visible or not in the grid.
Property Get Columns() As Long
Gets the number of columns in the grid, including hidden and RowText columns.
Property Get Rows() As Long
Gets/sets the number of rows in the grid.
Property Let Rows(RHS As Long)
Gets/sets the number of rows in the grid.
Sub AddRow(Optional ByVal lRowBefore As Long=-1, ByVal sKey As String, Optional ByVal
bVisible As Boolean=True, Optional ByVal lHeight As Long=-1, Optional ByVal bGroupRow As
Boolean=False, Optional ByVal lGroupColStartIndex As Long=0)
Adds or inserts a row to the grid.
Sub RemoveRow(ByVal lRow As Long)
Deletes a row from the grid.
Property Get RowVisible(ByVal lRow As Long) As Boolean
Gets/sets whether a row is visible in the grid or not.
Property Let RowVisible(ByVal lRow As Long, RHS As Boolean)
Gets/sets whether a row is visible in the grid or not.
Sub Clear(Optional ByVal bRemoveCols As Boolean=False)
Clears the rows from the grid, optionally removing the columns too.
Property Get BorderStyle() As ECGBorderStyle
Gets/sets the border style for the control.
Property Let BorderStyle(RHS As ECGBorderStyle)
Gets/sets the border style for the control.
Function FindSearchMatchRow(ByVal sSearchString As String, Optional ByVal bLoop As
Boolean=True, Optional ByVal bVisibleRowsOnly As Boolean=True) As Long
Finds the first matching row for a given search string.
Sub CancelEdit
Call to cancel an edit request when the control you are using to edit a cell looses focus.
Sub AutoWidthColumn(ByVal vKey As Variant)
Automatically resizes a column to accommodate the largest item.
Sub AutoHeightRow(ByVal lRow As Long, Optional ByVal lMinimumHeight As Long=-1)
Automatically sets the height of a row based on the contents of the cells.
Events

Public Event ColumnClick(ByVal lCol As Long)


Raised when the user clicks a column.
Public Event ColumnWidthStartChange(ByVal lCol As Long, ByVal lWidth As Long, ByVal bCancel
As Boolean)
Raised when the user is about to start changing the width of a column.
Public Event ColumnWidthChanging(ByVal lCol As Long, ByVal lWidth As Long, ByVal bCancel
As Boolean)
Raised whilst a column's width is being changed.
Public Event HeaderRightClick(ByVal x As Single, ByVal y As Single)
Raised when the user right clicks on the grid's header.
Public Event SelectionChange(ByVal lRow As Long, ByVal lCol As Long)
Raised when the user changes the selected cell.
Public Event RequestEdit(ByVal lRow As Long, ByVal lCol As Long, ByVal iKeyAscii As Integer,
ByVal bCancel As Boolean)
Raised when the grid has the Editable property set to True and the user's actions request editing of the
current cell.
Public Event CancelEdit

Public Event KeyDown(ByVal KeyCode As Integer, ByVal Shift As Integer, ByVal bDoDefault As
Boolean)
Raised when a key is pressed in the control.
Public Event KeyPress(ByVal KeyAscii As Integer)
Raised after the KeyDown event when the key press has been converted to an ASCII code.
Public Event KeyUp(ByVal KeyCode As Integer, ByVal Shift As Integer)
Raised when a key is released on the grid.
Public Event MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single,
ByVal y As Single, ByVal bDoDefault As Boolean)
Raised when the a mouse button is pressed over the control.
Public Event MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single,
ByVal y As Single)
Raised when the mouse moves over the control, or when the mouse moves anywhere and a mouse
button has been pressed over the control.
Public Event MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal x As Single, ByVal y
As Single)
Raised when a mouse button is released after having been pressed over the control.
Public Event DblClick(ByVal lRow As Long, ByVal lCol As Long)
Raised when the user double clicks on the grid.
Public Event RequestRow(ByVal lRow As Long, ByVal sKey As String, ByVal bVisible As Boolean,
ByVal lHeight As Long, ByVal bGroupRow As Boolean, ByVal bNoMoreRows As Boolean)
Raised when the grid is in Virtual mode and the grid has been scrolled to expose a new row. Set
bNoMoreRows to True to indicate all rows have been added.
Public Event RequestRowData(ByVal lRow As Long)
Raised in virtual mode when a new row has been added in response to RequestRow. Respond by filling
in the cells for that row.
Public Event ColumnOrderChanged

ENCRYPTAGE/DECRYPTAGE

Le code se compose de deux fonctions publiques vous permettant d'encrypter et de décrypter un


message. L'aspect intéressant réside dans le fait que vous pouvez crypter un message soit un
nombre de fois, soit jusqu'à ce qu'il atteigne une certaine taille.

La méthode de cryptage est basée sur la conversion des caractères du code ASCII (8-bits) vers un
autre dictionnaire (6-bits). Si vous avez des questions sur le code, n'hésitez pas à me contacter.

Sauvez le code dans un module et amusez-vous.

Option Explicit
' ****************************************************************************
' *** Fonctions de cryptage/décryptage ***************************************
' ****************************************************************************
' * N'hésitez pas à m'envoyer un mail si: *
' * - Vous souhaitez me donnez vos impressions *
' * - Vous avez envie de me faire partager des modifications de code que vous*
' * auriez faites. *
' ****************************************************************************
' * AUTEUR: FlyKiller. *
' ****************************************************************************
Private Const CodeChars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-/"
Public Enum CryptMethods
cmRaiseLenght
cmNumberOfTime
End Enum
Private Enum BitCoding
bc6Bits = 5
bc8Bits = 7
End Enum
Public Enum SerialTypes
stInvalid = 0
stUnlimited = 1
stTimeLimitedA = 2
stTimeLimitedB = 4
stTimeLimitedC = 8
End Enum
' ****************************************************************************
' * Function CryptMsg *
' *--------------------------------------------------------------------------*
' * PARAMETRES: *
' * - Msg: message à crypter. *
' * - CryptMethod: spécifie si il faut crypter x fois (NumberOfTime) ou *
' * jusqu'à ce que le message crypté arrive à une taille *
' * limite (RaiseLength) *
' * - CryptLimit: nombre de fois qu'il faut crypter (si NumberOfTime) ou *
' * taille maximale que le message crypté ne peut dépasser *
' * (si RaiseLength) *
' *--------------------------------------------------------------------------*
' * VALEURS RETOURNEES: *
' * - Retour de la fonction: Message crypté. *
' * - CryptLimit: Nombre de fois que le message a été réellement crypté. *
' * (Utile pour décrypter le message s'il a été encrypté *
' * plusieurs fois de suite) *
' ****************************************************************************
Public Function CryptMsg(ByVal Msg As String, _
Optional ByVal CryptMethod As CryptMethods = cmNumberOfTime, _
Optional ByRef CryptLimit As Integer = 1) As String
Dim BS As String
Dim I As Integer

If CryptMethod = cmNumberOfTime Then


For I = 1 To CryptLimit
BS = GetBitString(Msg, bc8Bits)
Msg = GetConvertedString(BS, bc6Bits)
Next
CryptMsg = Msg
Else
I=0
While Len(Msg) < CryptLimit
BS = GetBitString(Msg, bc8Bits)
Msg = GetConvertedString(BS, bc6Bits)
If Len(Msg) <= CryptLimit Then CryptMsg = Msg: I = I + 1
WEnd
CryptLimit = I
End If
End Function

' ****************************************************************************
' * Function UncryptMsg *
' *--------------------------------------------------------------------------*
' ****************************************************************************
Public Function UncryptMsg(ByVal Msg As String, _
Optional ByVal UncryptRepeat As Integer = 1) As String
Dim BS As String

BS = GetBitString(Msg, bc6Bits)
UncryptMsg = GetConvertedString(BS, bc8Bits)
End Function

' ****************************************************************************
' * [Function GetBitString] *
' *--------------------------------------------------------------------------*
' ****************************************************************************
Private Function GetBitString(ByVal Msg As String, _
ByVal BitPerChar As BitCoding) As String
Dim LetterIdx As Integer
Dim AscLetter As Integer
Dim BitIdx As Integer

For LetterIdx = 1 To Len(Msg)


If BitPerChar = bc8Bits Then
AscLetter = Asc(Mid$(Msg, LetterIdx, 1))
Else
AscLetter = InStr(CodeChars, Mid$(Msg, LetterIdx, 1)) - 1
End If
For BitIdx = BitPerChar To 0 Step -1
If AscLetter And 2 ^ BitIdx Then
GetBitString = GetBitString & "1"
Else
GetBitString = GetBitString & "0"
End If
Next
Next
End Function

' ****************************************************************************
' * [Function GetConvertedString] *
' *--------------------------------------------------------------------------*
' ****************************************************************************
Private Function GetConvertedString(ByVal BitString As String, _
ByVal BitPerChar As BitCoding) As String
Dim LetterIdx As Integer
Dim AscLetter As Integer
Dim BitIdx As Integer

For LetterIdx = 1 To Len(BitString) Step BitPerChar + 1


AscLetter = 0
For BitIdx = 0 To BitPerChar
If Mid$(BitString, LetterIdx + BitIdx, 1) = "1" Then
AscLetter = AscLetter Or (2 ^ (BitPerChar - BitIdx))
End If
Next
If BitPerChar = bc8Bits Then
GetConvertedString = GetConvertedString & Chr$(AscLetter)
Else
GetConvertedString = GetConvertedString & Mid$(CodeChars, AscLetter + 1, 1)
End If
Next
End Function

CHANGER LE MOT DE PASSE D'UNE BASE ACCESS

Public Function ChangerMotDePasse(CheminBase As String, NouveauPass As String, VieuxPass As


String) As Boolean
On Error Resume Next

If Dir(CheminBase) = "" Then Exit Function

Dim db As DAO.Database

Set db = OpenDatabase(CheminBase, True, False, ";pwd=" & VieuxPass)


If Err.Number <> 0 Then
ChangerMotDePasse = False
Exit Function
End If
db.NouveauPass VieuxPass, NouveauPass
ChangerMotDePasse = True
db.Close

End Function

' Pour changer le mot de passe :


Dim ChangerPass As Boolean
ChangerPass = ChangerMotDePasse("c:\LeChemin\
LeFichier.mdb","AncienPass","NouveauPass","AncienPass")

If ChangerPass = True Then


MsgBox("Mot de passe bien changé")
Else
MsgBox("Mot de passe non changé")
End If

Animer les GIFs


Please feel free to download any of the following source code and use them without charge in your
applications. This code is provided without warranty of any kind. Use at your own risk as we can not take
responsibility for any of this information or code. Home
http://www.asmincorp.com/software/dxanimatedgif/dxanimatedgif.zip
http://www.asmincorp.com/software/dxanimatedgif/dxanimatedgif.zip100% FREE animated GIF control for
use in your applications! This control DOES NOT use the web browser control. Please see the very brief
README.TXT file for some instructions. PLEASE NOTE: THIS OCX REQUIRES THE VB6 RUNTIME
FILES TO OPERATE CORRECTLY!!!

Just released 11/04/99, version 1.3 fixes a number of problems. The transparancy works, the dropped
frame is fixed, the inability to display some GIF files is fixed, etc. The only remaining "problems" are that
the control always refreshes the background thus erasing some GIFs that expect each frame to remain.
Download
Using Windows NT and VB6 you receive the error message "System Error &H80004002 (-2147467262)
No such interface supported." The culprit here is a rogue version of COMCAT.DLL. The version which
comes with VB6 is 4.71 and if you somehow get version 5.0, this error will occur. Simply unregister the
version 5.0 DLL, replace it with the correct version 4.71 off the VB6 CD and re-register. Tip!

You install VB6, and then compile a VB5 install on your machine... Then you install the VB5 application
on another PC. You may get the error "The Jet VBA file (VBAJET.DLL for 16-bit versions, or
VBAJET32.DLL for 32-bit versions) failed to initialize when called. Try reinstalling the application(s) that
returned the error." You need to add the EXPSRV.DLL to your VB5 install since VB6 updated DAO. Tip!
http://www.asmincorp.com/sourceandtips/50003.zip

http://www.asmincorp.com/sourceandtips/50003.zipIf you are getting a 50003 error related to a form which


has a tab control, this patch may fix your problem. We don't know exactly why...but it has always worked.
Simply download the ZIP, unzip it (the file name will be PATCH.REG) then run REGEDIT PATCH.REG.
Download
The ParameterCount and ParameterValue routines allow you to extract portions of a text string. For
example, if the string is "This,is,a,test" and the ParseCharacter is a comma...ParameterCount will return 4
and ParameterValue will return "This" or "is" or "a" or "test" depending on the index provided. Simply cut
and paste the following code.

Public Function ParameterCount(ParseCharacter As String, tString As Variant) As Integer


Dim CurrentPosition As Integer
Dim ParseToPosition As Integer
Dim CurrentToken As Integer
Dim TempString As String
TempString = Trim(tString) + ParseCharacter
If Len(TempString) = 1 Then Exit Function
CurrentPosition = 1
CurrentToken = 1
Do
ParseToPosition = InStr(CurrentPosition, TempString, ParseCharacter)
CurrentToken = CurrentToken + 1
CurrentPosition = ParseToPosition + 1
Loop Until (CurrentPosition >= Len(TempString))
ParameterCount = CurrentToken - 1
End Function

Public Function ParameterValue(ParseCharacter As String, tString As Variant, Index As Integer) As


String
Dim CurrentPosition As Integer
Dim ParseToPosition As Integer
Dim CurrentToken As Integer
Dim TempString As String
TempString = Trim(tString) + ParseCharacter
If Len(TempString) = 1 Then Exit Function
CurrentPosition = 1
CurrentToken = 1
Do
ParseToPosition = InStr(CurrentPosition, TempString, ParseCharacter)
If Index = CurrentToken Then
' This was returning trim()'d
ParameterValue = Mid$(TempString, CurrentPosition, ParseToPosition - CurrentPosition)
Exit Function
End If
CurrentToken = CurrentToken + 1
CurrentPosition = ParseToPosition + 1
Loop Until (CurrentPosition >= Len(TempString))
End Function Source code
The INIGet and INIPut routines allow you to read and write to INI files. Simply cut and paste the following
code.

Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal


lpapplicationname As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal
lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal


lpapplicationname As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As
String) As Long

Public Function INIGet(Keyfilename, Keyarea, Keyname, Keydefault) As String


Dim a As String
Dim b As String
Dim C As String
Dim D As String
Dim E As String
Dim ReturnValue As Long
a = Keyarea
b = Keyname
C = Keydefault
D = Space$(144)
E = Keyfilename
ReturnValue = GetPrivateProfileString(ByVal a, ByVal b, ByVal C, ByVal D, Len(D), ByVal E)
INIGet = Left$(D, ReturnValue)
End Function

Public Sub INIPut(Keyfilename, Keyarea, Keyname, ByVal Keyvalue As String)


Dim a As String
Dim b As String
Dim C As String
Dim D As String
Dim ReturnValue As Long
a = Keyarea
b = Keyname
C = Keyvalue
D = Keyfilename
ReturnValue = WritePrivateProfileString(ByVal a, ByVal b, ByVal C, ByVal D)
End Sub

You might also like