borderAndreaVB free resources for Visual Basic developersborder
AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2017 Andrea Tincani
:: Remove a Record from an Array...

Author  

Andrea Tincani

Language  

VB4, VB5, VB6

Operating Systems  

Windows 95, 98 and NT
Module

Option Explicit

Private Type my_type
    field1 As String
    field2 As Long
    field3 As Integer
End Type

Const MAX_ARRAY = 10
Dim my_array(0 To MAX_ARRAY - 1) As my_type

'Delete the record RecPos (from 0 to MaxRecs)...MaxRecs is the maximum array dimension
Public Sub DeleteRecordFromMyArray(RecPos As Integer, MaxRecs As Integer)
    Dim i As Integer

   
'Move all the record forward by one position
    For i = RecPos To MaxRecs - 1
        my_array(i) = my_array(i + 1)
    Next
   
'Reset the last array record
    my_array(MaxRecs).field1 = ""
    my_array(MaxRecs).field2 = 0
    my_array(MaxRecs).field3 = 0
End Sub

Usage

Private Sub Command1_Click()
    DeleteRecordFromMyArray 3, MAX_ARRAY - 1
End Sub

:: Navigation

Home

Beginners Corner

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 09-05-2014 INSERTING IMAGE FILES DYNAMICALLAY IN CRYSTAL VIEWER USING VB6 AND MS ACCESS by vikasjains
icon 11-12-2012 Re: Please help me to solve this problem???? by GeoffS
icon 21-01-2008 Re: Find record, multiple result by noknok
icon 28-12-2007 Re: Find record, multiple result by stickleprojects
icon 29-04-2007 Re: Update Primary Key at run time by yronium
borderAndreaVB free resources for Visual Basic developersborder
borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2017 Andrea Tincaniborder