PDA

Click to See Complete Forum and Search --> : select case statement


Dec 16th, 1999, 03:01 AM
Private Sub List1_Click()
End Sub

Private Sub mnuExitItem_Click()
Dim response As Integer
response = MsgBox("Are you sure you want to Exit?", _
vbQuestion Or vbYesNo, "Exit")
If response = vbYes Then End
End Sub

Private Sub mnuHelpAbout_Click()
Dim msg As String

msg = "My Fantastic States Application" & vbCrLf & _
"By Terrence Temes" & vbCrLf & vbCrLf & _
"Copyright 1999 by Terrence Temes"

MsgBox msg, vbInformation, "About"
End Sub

Private Sub mnuOpenItem_Click()
MsgBox "You chose to Open a File."
End Sub

Private Sub Form_Load()
'these lines add items to the Combo1 list box
Combo1.AddItem "Arizona" '0
Combo1.AddItem "California" '1
Combo1.AddItem "Colorado" '2
Combo1.AddItem "Florida" '3
Combo1.AddItem "Idaho" '4
Combo1.AddItem "Kansas" '5
Combo1.AddItem "Montana" '6
Combo1.AddItem "Nevada" '7
Combo1.AddItem "New Mexico" '8
Combo1.AddItem "Oregon" '9
Combo1.AddItem "South Dakota" '10
Combo1.AddItem "Washington" '11
End Sub
Private Sub Combo1_Click()

Select Case Combo1.ListIndex

'these lines add items to the list1 List box
Case 0
Label2.Caption = "Phoenix"
lblname.Caption = "Cactus Wren"
lblflower.Caption = "Saguaro cactus blossom"
Image1 = LoadPicture("A:\arizonaC.gif")
Image2 = LoadPicture("A:\az_wren_cc1.jpg")
Image3 = LoadPicture("A:\AZ_cactus.jpg")
Image4 = LoadPicture("A:\AZseal.gif")
Case 1
Label2.Caption = "Sacramento"
lblname.Caption = "California Valley Quail"
lblflower.Caption = "Golden Poppy"
Image1 = LoadPicture("A:\califC.gif")
Image2 = LoadPicture("A:\Ca_quail.gif")
Image3 = LoadPicture("A:\CAPoppy.jpg")
Image4 = LoadPicture("A:\bird.gif")
Case 2
Label2.Caption = "Denver"
lblname.Caption = "Lark Bunting"
lblflower.Caption = "White and Lavender Columbine"
Image1 = LoadPicture("A:\coloradC.gif")
Image2 = LoadPicture("A:\CO_larkbunting.jpg")
Image3 = LoadPicture("A:\Columbine.jpg")
Image4 = LoadPicture("A:\bird.gif")
Case 3
Label2.Caption = "Tallahassee"
lblname.Caption = "Mockingbird"
lblflower.Caption = "Orange Blossom"
Image1 = LoadPicture("A:\floridaC.gif")
Image2 = LoadPicture("A:\Fl_mockingbird2.jpg")
Image3 = LoadPicture("A:\OrangeJuice.gif")
Image4 = LoadPicture("A:\bird.gif")
Case 4
Label2.Caption = "Boise"
lblname.Caption = "Mountain Bluebird"
lblflower.Caption = "Syringa - Mock Orange"
Image1 = LoadPicture("A:\idahoC.gif")
Image2 = LoadPicture("A:\Idaho_MountainBluebird.jpg")
Image3 = LoadPicture("A:\flower.gif")
Image4 = LoadPicture("A:\bird.gif")
Case 5
Label2.Caption = "Topeka "
lblname.Caption = "Western Meadowlark"
lblflower.Caption = "Sunflower"
Image1 = LoadPicture("A:\kansasC.gif")
Image2 = LoadPicture("A:\KA_medlark.gif")
Image3 = LoadPicture("A:\sunflow.gif")
Image4 = LoadPicture("A:\sealtran.gif")
Case 6
Label2.Caption = "Helena "
lblname.Caption = "Western Meadowlark"
lblflower.Caption = "Bitterroot"
Image1 = LoadPicture("A:\montanaC.gif")
Image2 = LoadPicture("A:\MT_westernMead.jpg")
Image3 = LoadPicture("A:\flower.gif")
Image4 = LoadPicture("A:\bird.gif")
Case 7
Label2.Caption = "Carson City "
lblname.Caption = "Mountain Bluebird"
lblflower.Caption = "Sagebrush"
Image1 = LoadPicture("A:\nevadaC.gif")
Image2 = LoadPicture("A:\NV_bird.jpg")
Image3 = LoadPicture("A:\NVsagebrush.gif")
Image4 = LoadPicture("A:\bird.gif")
Case 8
Label2.Caption = "Santa Fe"
lblname.Caption = "Roadrunner"
lblflower.Caption = "Yucca flower"
Image1 = LoadPicture("A:\newmexC.gif")
Image2 = LoadPicture("A:\NM_roadrun.jpg")
Image3 = LoadPicture("A:\flower.gif")
Image4 = LoadPicture("A:\bird.gif")
Case 9
Label2.Caption = "Salem"
lblname.Caption = "Western Meadowlark"
lblflower.Caption = "Oregon grape"
Image1 = LoadPicture("A:\oregonC.gif")
Image2 = LoadPicture("A:\OR_medlark.gif")
Image3 = LoadPicture("A:\flower.gif")
Image4 = LoadPicture("A:\bird.gif")
Case 10
Label2.Caption = "Pierre"
lblname.Caption = "Ring-necked Pheasant"
lblflower.Caption = "Pasque Flower"
Image1 = LoadPicture("A:\sdakotaC.gif")
Image2 = LoadPicture("A:\SD_ringneck.jpg")
Image3 = LoadPicture("A:\SDpasque.gif")
Image4 = LoadPicture("A:\SDseal.gif")
Case 11
Label2.Caption = "Olympia"
lblname.Caption = "Willow goldfinch"
lblflower.Caption = "Coast Rhododendron"
Image1 = LoadPicture("A:\washC.gif")
Image2 = LoadPicture("A:\WA_mage-goldfinch1.jpg")
Image3 = LoadPicture("A:\WAsymrhody.jpg")
Image4 = LoadPicture("A:\WAsymseal.gif")

End Select
End Sub

[This message has been edited by strabos (edited 12-19-1999).]

MartinLiss
Dec 16th, 1999, 03:17 AM
Your post is truncated. Please edit it or try posting it again.

------------------
Marty

Gimpster
Dec 16th, 1999, 03:18 AM
Is that everything that you have for your code?

------------------
Ryan
corneslen@hotmail.com
ICQ# 47799046

DiGiTaIErRoR
Dec 16th, 1999, 04:47 AM
Try this:

in combo1 on select
-
If combobox1.text = "California" Then
"Sacromento" list1.addlist
"Las Angelos" list1.addlist
etc. for each city
End If
-

Or if you wanted to predefine you could make 50 lists if u have the time!
Good luck!

------------------
DiGiTaIErRoR

minnal
Dec 16th, 1999, 11:35 AM
Hi,

when u use a combo box avoid using the click event .Try using the same code with the lost focus or change event.