Anything like STRUCT in VBA?

N

NateBuckley

Hello I need to return about 4 pieces of data, two of type string and two of
type integer. I could create a Class and do it that way, but I'm only going
to need to send this data back once, and within this one module, so I thought
it may be better coding practice to just use something like a STRUCT?

Is there perhaps a way to create a STRUCT data type and return that?

Thanks for any help.

Nate
 
A

Andy Pope

Hi,

See help on the TYPE for creating user-defined data type containing one or
more elements

Cheers
Andy
 
J

JW

Hello I need to return about 4 pieces of data, two of type string and two of
type integer. I could create a Class and do it that way, but I'm only going
to need to send this data back once, and within this one module, so I thought
it may be better coding practice to just use something like a STRUCT?

Is there perhaps a way to create a STRUCT data type and return that?

Thanks for any help.

Nate

Private Type yourType
string1 As String
string2 As String
int1 As Integer
int2 As Integer
End Type

Sub example()
Dim yType As yourType
yType.string1 = "hello"
yType.string2 = "you"
yType.int1 = 12
yType.int2 = 34
End Sub
 
J

JW

Private Type yourType
    string1 As String
    string2 As String
    int1 As Integer
    int2 As Integer
End Type

Sub example()
    Dim yType As yourType
    yType.string1 = "hello"
    yType.string2 = "you"
    yType.int1 = 12
    yType.int2 = 34
End Sub

Welp, looks like I'm a little late. lol. Glad you got what you
needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top