Solved

Structures in VB

Posted on 1998-06-09
3
213 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
[X]
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
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code 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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

696 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