chatelain Posted October 25, 2005 Posted October 25, 2005 Dumb question that I can't resolve..(cuz I'm dumb) So I have a class with a property called AttachmentPath which is an arraylist. I would like to store the size of the attachment along with the path and if I understand it correctly, the Arraylist collection is one-dimensional. Can I get some ideas on how to store the size of the attachment and use a getAttachmentSize function to have that returned? Thanks in advance, Aaron Quote
Leaders snarfblam Posted October 26, 2005 Leaders Posted October 26, 2005 Why not create a structure and then create an arraylist to hold that structure. Not that I think that this is something over your head, but here is a quick example. 'You can add/remove members as necessary to hold all relevant info Public Structure AttatchmentInfo Dim Path As String, Size As Long Public Sub New(ByVal Path As String, ByVal size As Long) Me.Path = Path Me.Size = size End Sub Public Sub TestFunction() Dim List As New System.Collections.ArrayList 'Create a list of AttatchmentInfos List.Add(New AttatchmentInfo("C:\\Don\\Run", 100)) List.Add(New AttatchmentInfo("Run\\Don\\Run", 102)) 'Example of how to access info '(elements must be cast to AttatchmentInfo) MessageBox.Show("Att. 1 Path: " & _ DirectCast(List(0), AttatchmentInfo).Path) MessageBox.Show("Att. 2 Size: " & _ DirectCast(List(1), AttatchmentInfo).Size.ToString) End Sub End Structure Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.