?
Solved

Structures in VB

Posted on 1998-06-09
3
Medium Priority
?
214 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

764 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