Solved

Structures in VB

Posted on 1998-06-09
3
206 Views
Last Modified: 2010-05-03
I learned to program in Pascal and then advanced programing in C/C++ on Unix/Dos machines.  I am now stuck writing a VB program in Excel and I can't find an object or variable that behaves like a structure from C.  I just want a variable that I can use in all my modules and can be organized like this:
variablename.onedimessionalarray_of_title_for_data(0)
variablename.twodimessionalarray_of_data(0,0)
It is basicly an array that is capable of holding different data types in each element including other arrays.
0
Comment
Question by:Hosehead
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 100 total points
ID: 1462925
'Type' is VB's version of a structure

It's used as such:
Type tUDT
  Var1 As String
  Var2 As Integer
End Type
Dim UDTVar As tUDT

and then each element would be referenced as:
UDTVar.Var1 = "This is a string"
UDTVar.Var2 = 123
0
 

Author Comment

by:Hosehead
ID: 1462926
Quick question, can Var1 and Var2 be set as arrays of strings and integers?
0
 
LVL 6

Expert Comment

by:clifABB
ID: 1462927
Yep.
Type tUDF
  Var1(100) As String
  Var2(50) As Integer
End Type
Dim UDTVar As tUDT
'Or even
Din UDTArray(100) As tUDT


0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

705 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now