PC Review


Reply
Thread Tools Rate Thread

Anything like STRUCT in VBA?

 
 
NateBuckley
Guest
Posts: n/a
 
      2nd Jun 2008
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

 
Reply With Quote
 
 
 
 
Andy Pope
Guest
Posts: n/a
 
      2nd Jun 2008
Hi,

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

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"NateBuckley" <(E-Mail Removed)> wrote in message
news:12B40C12-0009-4F58-8251-(E-Mail Removed)...
> 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
>


 
Reply With Quote
 
NateBuckley
Guest
Posts: n/a
 
      2nd Jun 2008
Thanks matey thats precisly what I was looking for.

Cheers!

"Andy Pope" wrote:

> Hi,
>
> See help on the TYPE for creating user-defined data type containing one or
> more elements
>
> Cheers
> Andy
> --
>
> Andy Pope, Microsoft MVP - Excel
> http://www.andypope.info
> "NateBuckley" <(E-Mail Removed)> wrote in message
> news:12B40C12-0009-4F58-8251-(E-Mail Removed)...
> > 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
> >

>

 
Reply With Quote
 
JW
Guest
Posts: n/a
 
      2nd Jun 2008
On Jun 2, 7:48*am, NateBuckley <NateBuck...@discussions.microsoft.com>
wrote:
> 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
 
Reply With Quote
 
JW
Guest
Posts: n/a
 
      2nd Jun 2008
On Jun 2, 8:18*am, JW <JWRIGH...@triad.rr.com> wrote:
> On Jun 2, 7:48*am, NateBuckley <NateBuck...@discussions.microsoft.com>
> wrote:
>
> > 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


Welp, looks like I'm a little late. lol. Glad you got what you
needed.
 
Reply With Quote
 
NateBuckley
Guest
Posts: n/a
 
      2nd Jun 2008
Thanks for your reply anyways!

Cheers

"JW" wrote:

> On Jun 2, 8:18 am, JW <JWRIGH...@triad.rr.com> wrote:
> > On Jun 2, 7:48 am, NateBuckley <NateBuck...@discussions.microsoft.com>
> > wrote:
> >
> > > 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

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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
direct access to struct variables in List<struct> compiler error ? Bill Woodruff Microsoft C# .NET 1 24th Feb 2008 07:25 AM
Obtaining size of struct array-type member from fixed pack=1 struct? taskswap@gmail.com Microsoft C# .NET 4 12th Jan 2006 02:58 PM
Marshal struct with array size fixed of other struct (MyStruct[X]) Cyril Microsoft C# .NET 2 17th Nov 2005 08:55 AM
Converting a C struct to C# for a P/Invoke call (struct in structs and unions) Tom Hellström Microsoft Dot NET Framework 4 14th Jul 2005 01:10 PM
pinning member of struct -> entire struct pinned? Ben Schwehn Microsoft VC .NET 3 6th Jul 2004 05:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:43 PM.