Solved

Structures in VB

Posted on 1998-06-09
3
210 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

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

821 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