Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General 2 / May 2005



Tip: Looking for answers? Try searching our database.

Public variables in VB

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cricketunes@yahoo.com - 28 May 2005 02:02 GMT
Hi folks,
I am creating a Visual Basic application that uses 4 forms. I have a
list of data(2 types of cities) that I am storing into 2 arrays. Now
the contents of this array need to be shared across multiple forms.

I have two problems:

1) I tried to create a Public array in the Gen. Declaration section of
one of the forms, but it shouts a compile error and asks me not to make
arrays public. I really need the array data to be shared between
forms!! Which is the best place to put all the public variables.

2) I initially wanted to have a structure like this

Type CityInfo
CityName as String     'Atlanta
TicketCost as Integer  ' 136.43
End Type

and kept in the Module(.BAS file). When I tried to declare a public
variable in a form, it shouted out an error.

Any suggestions to overcome?

Thanks,
Cricket
[Newbie to VB]
Frank Adam - 28 May 2005 02:53 GMT
>1) I tried to create a Public array in the Gen. Declaration section of

>2) I initially wanted to have a structure like this
>
>Type CityInfo
>CityName as String     'Atlanta
>TicketCost as Integer  ' 136.43
>End Type

Right. You can not declare those in an *object* module as Public.
Classes and Forms are object modules.

If you want to share the data between the Forms, create a standard bas
module. In there you can then create your 'Public' types and arrays
and all forms will be able to access them.

Signature

Regards, Frank

Martin Trump - 28 May 2005 12:56 GMT
>TicketCost as Integer  ' 136.43

That looks strange to me.

Regards
Signature

Martin Trump

marks542004@yahoo.com - 28 May 2005 16:25 GMT
> >TicketCost as Integer  ' 136.43
>
[quoted text clipped - 3 lines]
> --
> Martin Trump

It's probably the rarely seen fractional integer data type.  ;)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.