Posted on 2004-04-16
Medium Priority
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 500 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 500 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 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