A New Data Programming Style

A New Data Programming Style

While working on VB projects with associated Jet databases, I found that I was creating a lot of individual handling functions for reading, writing, and validating data. It was hard to keep track of changes made to the table structures and to their associated handling functions.As a result, I’ve developed new programming style. My read /write and special functions are all in one routine selected by case logic based on descriptive strings. The strings are used only within the programs and are self documenting to some extent. Data is passed through a Public WorkVariant array:

 Public MyDB As DatabasePublic WorkVariant(10) As VariantDim Dummy As IntegerSet MyDB = OpenDatabase("testjet3db")'Sample callsDummy = NameTableIO("writerecord")Dummy = NameTableIO("readrecord")Public Function NameTableIO_	(ByVal whichAction As String) As Integer'Assumes navigation to the record has 'been made externallyDim MyTable As RecordsetDim ErrorStage As StringOn Error GoTo NameTableIOError	NameTableIO = True	ErrorStage = "OpenRecordSet"	Set MyTable = MyDB.OpenRecordset("NameTable")	ErrorStage = "AfterOpen"	Select Case whichAction		Case "readrecord"			WorkVariant(1) = MyTable![FirstName]			WorkVariant(2) = MyTable![Age]		Case "writerecord"			MyTable.Edit				MyTable![FirstName] = WorkVariant(1)				MyTable![Age] = WorkVariant(2)			MyTable.UpdateCase "validateage"	'specialized routine		'etcEnd SelectNameTableIOErrorExit:	If ErrorStage <> "OpenRecordSet" Then		MyTable.Close	End If	Set MyTable = NothingExit FunctionNameTableIOError:	NameTableIO = False	MsgBox Error$ &_		" Error trap in NameTableIO " & _		"at " & ErrorStage & " Action: " & whichAction	Resume NameTableIOErrorExitEnd Function
See also  11 Effective Keyword Research Tools and Techniques

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist