You are here VB6/VBA programming guide to create unicode ListView with BSAC

VB6/VBA programming guide to create unicode ListView with BSAC

VB6/VBA programming guide to create unicode ListView with BSAC

ListView in Microsoft's old activeX suite programmed for VB6, VBA does not support unicode, 64-bit, they have stopped developing. BSAC with BSListView is an alternative solution to support unicode and 64-bit along with many of the latest properties.

This article guides how to program VBA with BSListView control to create ListView displaying unicode, displaying images/icons.
 
1. Install activex BSAC.ocx
 
This only needs to be done the first time. If you install Add-in A-Tools will install automatically. If you want to download BSAC separately with sample examples, go here: https://atoolspro.com/products/bsac-bluesofts-activex-controls.html
 
2. Embed activex BSAC into project
+ In VB6:
- Create Project
- Go to menu Project->Components: find and select BSAC.ocx
(BSAC 32-bit at C:\Windows\SysWow64\)
 
+ In VBA:
- ALT+F11 (Go to Visual Basic Application)
- Go to menu Insert->Userform
- Go to menu Tools->References...: find and select BSAC.ocx
(BSAC 32-bit: at C:\Windows\SysWow64\
BSAC 64-bit: at C:\Windows\System32\)
 
 
See more at: https://atoolspro.com/install-activex-controls-bsac-manually.html
 
- Right click on Toolbox, select "Additional Controls..." then check the controls used for programming, such as BSImageList, BSListView, BSTreeView, BSListBox, BSComboBox, BSTaskPaneX, BSTooltip,...
 
 
3. Create an interface with ListView on Form/Userform
 
- Drag and drop BSListView into Form/Userform. Adjust the size and position appropriately
- Drag BSButton into the form, set Name: "cmdAdd", Text: "Add"
- Drag BSButton into the form, set Name: "cmdRemove", Text: Delete"
- Drag BSImageList into the form (to save the icon displayed for BSListView).
From the BSImageList control, you should set the ColorDepth property to cd32Bit to get full color images.
Right-click, select Properties, select (Custom) in the Properties window, load the images (icon, jpec, png...) into the control.
 
Set the Font of the controls to "Tahoma".
 
4. Programming to display ListView with unicode with BSListView control
'SOURCE CODE BEGIN-------- 
Option Explicit 
'BSAC.BSListView: create ListView with unicode
'Use UNC() convert VNI/TCVN3 to unicode
Private Sub cmdAdd_OnClick() 
   'Add row (BSListItem)
   Dim li As BSListItem, I As Long 
   I = BSListView1.Items.Count 
   Set li = BSListView1.Items.Add(UNC("NguyÔn Duy Tu©n ") & I + 1, 0) 
   'Add column
   li.SubItems.Add "01-01-1990", 1 
   li.SubItems.Add UNC("Tæng hîp d÷ liÖu"), 2 
End Sub 
'--------------------------------------------------
Private Sub cmdRemove_OnClick() 
   BSListView1.Selected.Delete 
End Sub 
'--------------------------------------------------
Private Sub UserForm_Initialize() 
   'Setup BSListView
   'Thiet lap ImageList to BSListView
   Set BSListView1.ImageList = BSImageList1 
   BSListView1.View = vsReport 
   BSListView1.RowSelect = True 
   'Add columns to BSListView
   'Column: Caption, Width, ImageIndex
   ' Caption: use UNC() convert VNI/TCVN3 to unicode
   Dim lc As BSListColumn 
   Set lc = BSListView1.Columns.Add(UNC("Hä Vµ Tªn"), 150, 0) 
   Set lc = BSListView1.Columns.Add(UNC("Ngµy Sinh"), 120, 1) 
   lc.Alignment = taCenter 
   Set lc = BSListView1.Columns.Add(UNC("Chøc Vô"), 120, 2) 
End Sub 
'SOURCE CODE END--------------
'If VB6 change the event name "UserForm_Initialize()" to "Form_Load()"
After running you will get the screen as shown below: