Results 1 to 5 of 5

Thread: select case statement

  1. #1
    Guest

    Post

    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).]

  2. #2
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Post

    Your post is truncated. Please edit it or try posting it again.

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

  3. #3
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    Is that everything that you have for your code?

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

  4. #4
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    Try this:
    Code:
    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

  5. #5
    Junior Member
    Join Date
    Nov 1999
    Location
    chennai,tamilnadu,india
    Posts
    18

    Post

    Hi,

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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width