Posted on 2004-04-16
Last Modified: 2010-05-02
Hi there,

I'm REALLY struggling with doing records in VB. Currently I've got:

on main form:
a list box
a few edit boxes

in a module:
Public Type Data
    activity As String
    description As String
    tl As Integer
    tr As Integer
    bl As Integer
    br As Integer
    est As Long
    min As Long
    max As Long
End Type

What I'm wanting to do is create a few records of the type Data and have each record that is created have the activity field shown in the list box. There may be many similarities between the records including the activity field. I'm also wanting to save the records to a text file (in order) and maybe have an option to load them in again.

I'm quite happy to give it a go myself but I just can't seem to figure out how to create records??? Also I won't know until runtime how many records I'll need.

Can anybody help?
Question by:Sphinx5
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

ramesh12 earned 125 total points
ID: 10844269
You should use some thing like this in your form

create an empty array of the type you created like

dim x() as data

now whenever you want to add records use like this

redim preserve x(ubound(x)+1)



This is not perfect. BUt hope this gives you a start


Assisted Solution

___XXX_X_XXX___ earned 125 total points
ID: 10849339
If you plan to save these records in file, you must set fixed length string in it's members or you will have problems storing such records in file, because if string members (activity and description) are with variable length, how will you know what is the length of each record when you save to file ? In fact, now with these variable length string members in your structre, they "occupy" 4 bytes because String is a pointer. Better declare type like this:
Public Type Data
    activity As String*255 ' Replace 255 with some number that can fix to your needs.
    description As String*255 ' Same here
    tl As Integer
    tr As Integer
    bl As Integer
    br As Integer
    est As Long
    min As Long
    max As Long
End Type

This structure is more easy to save/read from file.

Author Comment

ID: 10887742
Cheers guys! :)

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Recommendation vb6 to or others 14 210
Child Form in front 4 57
which modules are active in VB6 project? 6 52
Dinamic report to Crosstab query 9 53
Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question