Use A Class To Convert Code

In VB3 if you wanted to convert your code from one custom control toanother, there were no options other than changing your code. By writingthe proper class you can make use of your current syntax with a differentcontrol. This code demonstrates how to write a VB class to change standardlist-box syntax to use a ListView control. MyList.AddItem and .RemoveItemmethods and the .Text property will interface to the ListView Control usingthis class:

 'Form1 would have a listView control on it'dim a module wide object variableDim MyList As ObjectPrivate Sub Form_Load()	'create an instance of our class	Set MyList = New FakeList	'tell the class what control to use	Set MyList.ListItem = ListView1End Sub'The Class code follows'This holds the listview control'that we will interface withPublic ListItem As ListViewPublic Sub AddItem(sString As String)	'convert AddItem to Add	ListItem.ListItems.Add , , sStringEnd SubPublic Sub RemoveItem(lItem As Long)	'Convert RemoveItem to Remove	ListItem.ListItems.Remove lItemEnd SubPublic Property Get Text() As String	'Get the text from the selected item	Text = ListItem.SelectedItem.TextEnd PropertyPublic Property Let Text(sString As String)	'set the text in the selected item	ListItem.SelectedItem.Text = sStringEnd Property
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet