The following code is supposed to use the data in the attatched file to generate a list of relavent houses available based on the specifacations that you enter. After I enter my prefered search method I can't get it to stop asking me how many bed/bathrooms or what price i want to search for. Could you guys help me out?

Here is the code:

'Ananda Bennett
'11/06/2006
'HHSS
OPEN "c:\homes.txt" FOR INPUT AS #1
PRINT"************************************"
PRINT"* 1 - Search by number of bedrooms *"
PRINT"* 2 - Search by number of bathrooms*"
PRINT"* 3 - Search by price *"
PRINT"************************************"
INPUT "What would you like to search for homes by?: "; schoice
CLS
DO WHILE EOF(#1) <> -1
INPUT #1, address$, city$, state$, proptype$, bedrooms, bathroom, price
SELECT CASE schoice
CASE 1
INPUT "How many bedrooms would you like to search by?; "; bedquant
IF bedquant = bedroom THEN
PRINT "Address: "; address$
PRINT "City: "; city$
PRINT "State: "; state$
PRINT "Prop. Type: "; proptype$
PRINT "Bedrooms: "; bedrooms; "Bathrooms: "; bathrooms; "Price: "; price;
PRINT "-----------------------------------------------------------------"
END IF
CASE 2
INPUT "How many bathrooms would you like to search by?; "; bathquant
IF bathquant = bedroom THEN
PRINT "Address: "; address$
PRINT "City: "; city$
PRINT "State: "; state$
PRINT "Prop. Type: "; proptype$
PRINT "Bedrooms: "; bedrooms; "Bathrooms: "; bathrooms; "Price: "; price;
PRINT "-----------------------------------------------------------------"
END IF
CASE 3
INPUT "What price would you like to search by?; "; prices
IF prices = price THEN
PRINT "Address: "; address$
PRINT "City: "; city$
PRINT "State: "; state$
PRINT "Prop. Type: "; proptype$
PRINT "Bedrooms: "; bedrooms; "Bathrooms: "; bathrooms; "Price: "; price;
PRINT "-----------------------------------------------------------------"
END IF
END SELECT
LOOP

Ananda:twisted:

Edited 3 Years Ago by Dani: Fixed formatting

Attachments
33856 Foxborough Way,Lake Forest,CA,Residential,4,2.50,320000
284 Huntington,Mission Viejo,CA,Residential,4,2,290000
798G5,Lake Forest,CA,Condo,3,2.50,123000
13133 Spencer,Canyon Areas,CA,Residential,3,2.50,227500
14770 Poinsettia,Rancho Santa Margarita,CA,Residential,4,2.75,235000
910 Garden,Mission Viejo,CA,Residential,4,2.50,249900
11849 Goodale,Laguna Hills,CA,Residential,4,2,249900
32504 Devonshire,Rancho Santa Margarita,CA,Townhome,2,2,163900
9141 Westminster,Mission Viejo,CA,Residential,4,3,290000
33703 Ancona,Laguna Hills,CA,Townhome,2,2,150000
14673 Swan Lane,Mission Viejo,CA,Residential,4,4.25,750000
35764 Spadra,Mission Viejo,CA,Residential,3,2,184000
17300 Newhope #27,Laguna Hills,CA,Residential,4,2.50,239900
37091 La Fuente,Laguna Hills,CA,Condo,3,2.50,174500
13041 Brookhaven Park,Lake Forest,CA,Residential,3,1.75,209999
118 Mira Mesa,Coto De Caza,CA,Condo,2,2,139500
13221 Le Ann Drive,Mission Viejo,CA,Residential,3,1.75,187500
13610 Briarglen "B",Laguna Beach,CA,Residential,3,1.75,175900
20121 Outpost,Dana Point,CA,Residential,3,2.50,239900
23641 Seven Seas Drive,Laguna Hills,CA,Residential,3,2.50,190990
39 Sarracenia,Lake Forest,CA,Residential,3,2,214900
38301 Virginia,Mission Viejo,CA,Residential,3,1.75,194900
35633 Via Tequila,Laguna Niguel,CA,Condo,2,1,98500
12753 Edwards,Mission Viejo,CA,Residential,4,2.50,287500
4 Bravo Lane,Rancho Santa Margarita,CA,Residential,5,5.50,729000
35863 Via San Fernando,Mission Viejo,CA,Residential,5,2.75,289900
36911 Windsor,Lake Forest,CA,Residential,3,2.50,209000
6094 Greenbrier Drive,Mission Viejo,CA,Residential,4,2.50,484900
14861 Las Solanas,Laguna Hills,CA,Residential,4,2.75,399900
31151 Cedar Lane,Mission Viejo,CA,Condo,2,2,299900
9189 El Molino Circle,Mission Viejo,CA,Residential,3,2,189900
36691 Manzaneres,Mission Viejo,CA,Condo,2,2.50,162900
38856 Curlew,Mission Viejo,CA,Condo,2,2.50,169900
17387 Flame Tree,Laguna Hills,CA,Residential,3,2.75,269900
36033 Nellie Gail Road,Mission Viejo,CA,Residential,2,2.50,224900
3369 Avalon Street,Mission Viejo,CA,Condo,3,3,159900
17693 Gainsford Lane,Rancho Santa Margarita,CA,Residential,4,3,252900
18485 Hawthorn Street,Mission Viejo,CA,Residential,4,2.50,269900
13093 Janette,Laguna Hills,CA,Residential,3,2.50,245000
35 Woodleaf,Laguna Hills,CA,Condo,3,3,139900
10263 Rainbow Circle,Mission Viejo,CA,Residential,4,2.50,209000
34621 Orchard Rim Lane,Lake Forest,CA,Residential,5,2.50,300000
10047 San Miguel Court,Canyon Areas,CA,Residential,3,2,199000
17744 La Rosa,Mission Viejo,CA,Residential,4,3,319900
17291 Ash,Mission Viejo,CA,Residential,3,1.75,174900
1519 Lakeside,Laguna Hills,CA,Residential,3,1.75,192900
3485 Fairway Drive,Mission Viejo,CA,Residential,4,3.50,449000
32539 El Greco,Mission Viejo,CA,Residential,3,2,169900
31194 Briarwood Lane,Mission Viejo,CA,Residential,3,2.50,177900
313 Avenida La Cuesta,Mission Viejo,CA,Residential,4,2.50,279900
51 Via Gatillo,Mission Viejo,CA,Residential,3,2.50,195900
9926 Petunia Avenue,Mission Viejo,CA,Residential,4,2.50,314900
20536 Via Estoril,Mission Viejo,CA,Condo,2,1.75,101000
10371 Kern Avenue,Canyon Areas,CA,Residential,4,3,349900
106 Mira Mesa,Lake Forest,CA,Residential,4,2,199900
37723 Sinsonte,Garden Grove,CA,Residential,3,2.50,274900
11182 Aconite,Aliso Viejo,CA,Residential,4,2.50,232000
33673 White Oaks,San Clemente,CA,Residential,3,1.75,188900
33356 Eucalyptus,Westminster,CA,Residential,2,1.50,102900
35933 Hendon,Garden Grove,CA,Residential,3,2,182500
21954 La Subida,Huntington Beach,CA,Condo,3,2.50,189900
35231 Encorvado,Fountain Valley,CA,Residential,3,1.75,199500
891 Tia Juana,Canyon Areas,CA,Residential,5,3.50,236000
9133 Healey Drive,Huntington Beach,CA,Residential,4,2.75,239900
3428 W California,Fountain Valley,CA,Residential,4,2.50,269900
37199 Via Aurora,Costa Mesa,CA,Residential,3,2.50,248900
34511 El Picador,Fountain Valley,CA,Residential,3,2,219500
6 Wildflower,Huntington Beach,CA,Residential,5,4.50,795000
35353 Twig Street,Aliso Viejo,CA,Residential,3,2,179500
18 Alta Vista,Huntington Beach,CA,Residential,3,1.75,219900
16715 Bushard,Westminster,CA,Residential,4,2.50,245000
37173 Calle Juanita,Fountain Valley,CA,Residential,3,2.50,207000
11811 Timmy Lane,Fountain Valley,CA,Residential,4,2.75,227500
36621 La Sierra,Huntington Beach,CA,Condo,2,2.50,156500
37815 Emerald,Garden Grove,CA,Residential,3,2,189900
1 Coca,Fountain Valley,CA,Townhome,2,2,139900
604 Calle Canasta,Lake Forest,CA,Condo,2,2.50,145000
13720 Mistybrook,Aliso Viejo,CA,Residential,4,3,629000
13299 Oertley,Aliso Viejo,CA,Residential,4,3,222000
9600 Gardenia Avenue,Foothill Ranch,CA,Residential,4,4,419000
32645 Lexington Court,Laguna Beach,CA,Residential,3,2.50,319900
10491 Halelani,Garden Grove,CA,Residential,4,3,322900
15911 Vanguard,Huntington Beach,CA,Residential,4,3,379500
36441 San Torini,Huntington Beach,CA,Residential,3,3,380000
38166 Rancho Grande,Garden Grove,CA,Residential,3,2,219900
34933 Terra Bella Avenue,Garden Grove,CA,Residential,3,2,179900
6423 Cory Drive,Santa Ana,CA,Residential,4,3,322500
33953 Caminito Viento,Garden Grove,CA,Residential,4,1.75,199900
6 Glen Iris,Garden Grove,CA,Residential,4,2,189500
35623 Sadaba,Lake Forest,CA,Residential,3,1.75,173000
35181 Adonis,Garden Grove,CA,Residential,4,3,289900
37363 Ventosa,Mission Viejo,CA,Residential,4,2.50,264900
35123 Delphi,Garden Grove,CA,Residential,3,2,199900
36153 Buena Vista,Garden Grove,CA,Townhome,3,2.50,309000
34211 Derby Hill,Santa Ana,CA,Residential,3,3,214990
36763 Moore Oaks Road,Garden Grove,CA,Residential,5,2.75,297000
33 Charca,Mission Viejo,CA,Residential,2,2.75,229900
37165 Woodbluff,Garden Grove,CA,Residential,4,3,349900
34734 Nugget,Garden Grove,CA,Residential,3,2,210000
53 Diamondgate,Garden Grove,CA,Residential,4,2.50,229000
31561 Medina,Garden Grove,CA,Residential,4,2,244900
10 Spicewood,Santa Ana,CA,Residential,4,2.50,244900
35733 Clarington Drive,Garden Grove,CA,Condo,3,2.50,149900
43 Tamarac,Garden Grove,CA,Condo,2,2.50,149900
35193 Amurro Drive,Garden Grove,CA,Residential,3,2.50,239900
7 Via Gardenia,Garden Grove,CA,Residential,3,3,324000
37644 Nopales,Lake Forest,CA,Residential,3,2,165900
29 Inverary,Fountain Valley,CA,Residential,4,3,229000
17443 Woodfern,Stanton,CA,Residential,2,1,199900
36436 Sinforosa,Canyon Areas,CA,Residential,4,1.75,214900
13 Islay,Mission Viejo,CA,Residential,2,1.75,159000
49 Willowood,Canyon Areas,CA,Residential,2,1.75,169000
4176 Tortuga #106,Mission Viejo,CA,Residential,2,2,179000
33166 Crane,San Juan Capistrano,CA,Residential,4,1.75,204900
36401 Via Marina,Mission Viejo,CA,Residential,3,3,459000
21632 Crystal Sands,Mission Viejo,CA,Residential,4,3,219000
112 Cloudcrest,Mission Viejo,CA,Residential,3,2.50,229900
58 Hummingbird,Mission Viejo,CA,Residential,3,2,229900
31873 Ute Way,Mission Viejo,CA,Residential,3,2,169000
32931 Dory Drive,Mission Viejo,CA,Residential,3,2.50,190000
33221 Canyon Crest Drive,Mission Viejo,CA,Residential,7,5,895000
38721 Breckenridge,Mission Viejo,CA,Residential,4,2.50,314900
37131 Valia,Lake Forest,CA,Condo,2,2,144900
31191 Cranbridge,Mission Viejo,CA,Residential,4,2.75,227500
3162 Placentia,Mission Viejo,CA,Residential,3,2,179900
38431 Fieldbrook,Mission Viejo,CA,Residential,4,2.75,289900
35 Cloudcrest,Mission Viejo,CA,Residential,3,2,199900
31213 Monterra,Mission Viejo,CA,Condo,2,2,110900
16 Regalo Drive,Laguna Hills,CA,Residential,4,2.50,244900
18259 Mt Cherie,Mission Viejo,CA,Residential,3,1.75,173900
32378 Coso,Mission Viejo,CA,Residential,4,2,199900
50 La Costa,Mission Viejo,CA,Residential,3,2,172000
36935 Poppy Place,Coto De Caza,CA,Condo,2,2,129900
13191 Bangor,Mission Viejo,CA,Residential,4,3.50,374900
33391 Birchleaf,Laguna Niguel,CA,Residential,4,3,188500
33641 Shady Grove,Canyon Areas,CA,Condo,2,2,124000
34283 Spotted Pony Lane,Portola Hills,CA,Residential,2,1.50,179500
34166 Fairgreen,Mission Viejo,CA,Condo,3,2.50,164900
31114 Avenida Magnifica,Laguna Hills,CA,Residential,2,1.75,184900
37631 Soltero,Rancho Santa Margarita,CA,Residential,3,1.75,169900
36433 Avenida Veronica,Mission Viejo,CA,Residential,4,2.50,269900
35834 Via Princesa,Mission Viejo,CA,Residential,5,4,242500
31151 Ponderosa,Mission Viejo,CA,Residential,4,2.50,264900
33351 Terni,Aliso Viejo,CA,Residential,4,2.50,239900
35951 W. Sunset Place,Mission Viejo,CA,Condo,3,2.50,145000
36234 Eva,Mission Viejo,CA,Residential,4,3,384900
2 De Lila,Mission Viejo,CA,Residential,3,2.75,198900
33873 Springwater,Mission Viejo,CA,Residential,3,2.50,236400
321 Encantado Canyon,Mission Viejo,CA,Residential,4,2.50,281900
38503 Via Alfonse,San Juan Capistrano,CA,Condo,2,2,108500
21 San Bonifacio,Laguna Hills,CA,Residential,4,2.75,257500
36313 Mount Diablo,Lake Forest,CA,Residential,4,3.50,485000
33161 Bianco,Mission Viejo,CA,Residential,4,3,349900
36721 La Sierra,Lake Forest,CA,Residential,2,2,209000
121 Valley View,Coto De Caza,CA,Residential,4,3,284900
34854 Elderbrook Lane,Mission Viejo,CA,Residential,3,1.75,169900
18940 Canyon Hill,Laguna Hills,CA,Condo,2,1.50,110900
36833 Belleza,Mission Viejo,CA,Condo,3,2.50,274900
33 Blanco,San Juan Capistrano,CA,Residential,3,2.50,360000
34671 Cervantes Lane,Mission Viejo,CA,Residential,3,1.75,212500
33266 Estallens,Laguna Hills,CA,Residential,3,3.50,459000
31693 Alderbrook,Laguna Hills,CA,Condo,2,1.25,129900
61 Golf Ridge,Laguna Hills,CA,Residential,4,2,218900
30981 Sky Country,Mission Viejo,CA,Residential,4,3,244900
19121 Echo Pass,Lake Forest,CA,Residential,2,1.75,199000
34114 Windwood Lane,Coto De Caza,CA,Condo,3,2.50,162500
39 Invenary,Mission Viejo,CA,Condo,3,3,172500
36831 Via Matador,Laguna Hills,CA,Residential,2,1.75,179900
31121 Calle Ocaso,Mission Viejo,CA,Condo,3,2,169900
16 Via Barcaza,Laguna Niguel,CA,Residential,4,3.75,339900
9233 Bixby Avenue,Rancho Santa Margarita,CA,Residential,3,2,179900
34873 Eucalyptus,Lake Forest,CA,Residential,4,2.50,214900
17303 Corbina #308,Laguna Hills,CA,Residential,3,2,219000
16091 Jenner Street,Lake Forest,CA,Residential,3,2.50,299000
3 Alder Drive,Lake Forest,CA,Residential,3,3,439000
35786 Via San Marco,Mission Viejo,CA,Residential,2,1,165000
38541 Fieldbroo

Hi,

modify ur code this way,
remove the do while loop and the opening of txt file.
do not alter the select statemnet.

Print "************************************"
Print "* 1 - Search by number of bedrooms *"
Print "* 2 - Search by number of bathrooms*"
Print "* 3 - Search by price *"
Print "************************************"
INPUT "What would you like to search for homes by?: "; schoice
Input #1, address$, city$, State$, proptype$, bedrooms, bathroom, price
Select Case schoice
Case 1
INPUT "How many bedrooms would you like to search by?; "; bedquant
Open "c:\homes.txt" For Input As #1
DO WHILE EOF(#1) <> -1
If bedquant = bedroom Then
Print "Address: "; address$
Print "City: "; city$
Print "State: "; State$
Print "Prop. Type: "; proptype$
Print "Bedrooms: "; bedrooms; "Bathrooms: "; bathrooms; "Price: "; price;
Print "-----------------------------------------------------------------"
End If
Loop
Case 2
INPUT "How many bathrooms would you like to search by?; "; bathquant
Open "c:\homes.txt" For Input As #1
DO WHILE EOF(#1) <> -1
If bathquant = bedroom Then
Print "Address: "; address$
Print "City: "; city$
Print "State: "; State$
Print "Prop. Type: "; proptype$
Print "Bedrooms: "; bedrooms; "Bathrooms: "; bathrooms; "Price: "; price;
Print "-----------------------------------------------------------------"
End If
Loop
Case 3
INPUT "What price would you like to search by?; "; prices
Open "c:\homes.txt" For Input As #1
DO WHILE EOF(#1) <> -1
If prices = price Then
Print "Address: "; address$
Print "City: "; city$
Print "State: "; State$
Print "Prop. Type: "; proptype$
Print "Bedrooms: "; bedrooms; "Bathrooms: "; bathrooms; "Price: "; price;
Print "-----------------------------------------------------------------"
End If
Loop
End Select


Regards
Veena

Hi,

sorry, i forgot to tell u after end select, close the text file .

Regards

Veena

Thank you very much!

I know you already have a reply, but I'll stick my 2 cents in anyway.

Your basic logic progression is to have the buyer select the criteria by which to search the houses offered, then search the house list and compile an additional list of properties which fit the buyer's criteria. The problem with your original code is that the do-while loop includes the input string for each criteria choice, and it will reiterate those input queries for every record in the file. I didn't count how many there were in your sample file, but it looked like well over 100.

Here's what I would have done. I would first get the customer's criteria, then open the house file for input and compare each listing to the customer's criteria. I would put each bit of info from each listing that met the criteria into arrays. The arrays could then either be printed to paper, screen, or to another text file. My code would look something like this:

(I have not plugged the code in to test it, since this is just to give you a new approach to the problem.)


'Ananda Bennett
'11/06/2006
'HHSS


dim counter(1) 'counter variable for array use

'the following are arrays for building the buyer's choice list

dim buyer_bed (10000)
dim buyer_bath(10000)
dim buyer_price(10000)
dim buyer_address$(10000)
dim buyer_city$(10000)
dim buyer_state$(10000)
dim buyer_proptype$(10000)

'Code Starts here --------------------------------------------------------

counter = 0

OPEN "c:\homes.txt" FOR INPUT AS #1

PRINT"************************************"
PRINT"* 1 - Search by number of bedrooms *"
PRINT"* 2 - Search by number of bathrooms*"
PRINT"* 3 - Search by price *"
PRINT"************************************"

INPUT "What would you like to search for homes by?: "; schoice
SELECT CASE schoice

CASE 1
INPUT "How many bedrooms would you like to search by?; "; bedquant

DO WHILE EOF(#1) <> -1
INPUT #1, address$, city$, state$, proptype$, bedrooms, bathroom, price

IF bedquant = bedroom THEN

counter = counter + 1 'increment counter for array
buyer_bed (counter) = bedrooms
buyer_bath(counter) = bathroom
buyer_price(counter) = price
buyer_address$(counter) = address$
buyer_city$(counter) = city$
buyer_state$(counter) = state$
buyer_proptype$(counter) = proptype$

END IF
LOOP

CASE 2
INPUT "How many bathrooms would you like to search by?; "; bathquant

DO WHILE EOF(#1) <> -1
INPUT #1, address$, city$, state$, proptype$, bedrooms, bathroom, price

IF bathquant = bedroom THEN

counter = counter + 1 'increment counter for array
buyer_bed (counter) = bedrooms
buyer_bath(counter) = bathroom
buyer_price(counter) = price
buyer_address$(counter) = address$
buyer_city$(counter) = city$
buyer_state$(counter) = state$
buyer_proptype$(counter) = proptype$

END IF
LOOP

CASE 3
INPUT "What price would you like to search by?; "; prices

DO WHILE EOF(#1) <> -1
INPUT #1, address$, city$, state$, proptype$, bedrooms, bathroom, price

IF prices = price THEN

counter = counter + 1 'increment counter for array
buyer_bed (counter) = bedrooms
buyer_bath(counter) = bathroom
buyer_price(counter) = price
buyer_address$(counter) = address$
buyer_city$(counter) = city$
buyer_state$(counter) = state$
buyer_proptype$(counter) = proptype$

END IF
LOOP

END SELECT

CLOSE #1

for x = 1 to counter
PRINT "Address: "; address$
PRINT "City: "; city$
PRINT "State: "; state$
PRINT "Prop. Type: "; proptype$
PRINT "Bedrooms: "; bedrooms; "Bathrooms: "; bathrooms; "Price: "; price
print""
next x

This article has been dead for over six months. Start a new discussion instead.