Solved

Structures in VB

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

773 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