Avatar of DColin
DColinFlag for Thailand

asked on 

Global variables

Hi Experts,

I am using a web service API to retrieve holiday information, please consider the following pseudo code:

Sub ButtonOnClick_ApiGetCountryList

     countryList = webService.GetCountryList

End Sub

Sub ButtonOnClick_ApiGetHotelList

     hotelList = webService.GetHotelList(Country)

End Sub

Sub ButtonOnClick_ApiGetAirportList

     airportlList = webService.GetAirportlList(Country)

End Sub

Sub ButtonOnClick_ApiGetBeachlList

     BeachList = webService.GetBeachlList(Country)

End Sub

Once the user has clicked the get country button and the web service has delivered a list of countries I need a country from that list to be available to the other three subs. How do I do this without using a global variable or is it OK to use a global variable?
.NET Programming

Avatar of undefined
Last Comment
SAMIR BHOGAYTA
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Questions: How often does the webService information change regarding the lifetime of your app?
Is it a asp.net/winform project?
Are these lists used elsewhere in your app, appart  from the form/page you are displaying?

I will put countryList as global variable, but the others as cached form variables (say 5-10 minutes).
ASKER CERTIFIED SOLUTION
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

I would set it up as a class library, using stored procedure to pull your country information. Then you simply access it with one line of code in each section. Something like classLibraryName.className.attribute. In your example it a possibility would be clsLibrary.Country.countryName or clsLibrary.Country.countryID.


http://www.csunit.org/tutorials/tutorial6/
http://www.codeproject.com/KB/vb/OOPS_In_VBNET.aspx
Hi, you have to follow the these queries.

Into the webService.GetCountryList() query you have to write one more filter that the id of country is matched with the id of countryid which is into the hotellist table and the id of country is matched with the id of countryid which is into the airportlist table and the id of country is matched with the id of countryid which is into the beachlist table. You must have to one id field for storing the id of country into each table for relationships between these four tables.
.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo