question in select case

anonymous_at_discussions.microsoft.com
Date: 03/19/04


Date: Thu, 18 Mar 2004 19:08:23 -0800

You can not start object/variable name with a number
(1stData). Pick another name.

>-----Original Message-----
>
>
>What's wrong with this code.. I get an error in the
>statment
>
> name = 1stData.Items(1stData.SelectedIndex)
>
>Also.. I have another problem...
>
>If my current program has got any error, when the run
the
>program then it is giving me the output of my previous
>program.. what could possible be the reason.. I spent
>hours in figuring out.. Can someone help me..
>
>Here goes the code...
>
>
>
>
>
>
> Private Sub lstData_SelectedIndexChanged(ByVal sender
As
>System.Object, ByVal e As System.EventArgs) Handles
>lstData.SelectedIndexChanged
>
>
>
>'what did we choose?
>
>
> Dim name As String
> name = 1stData.Items(1stData.SelectedIndex)
>
> 'use a select case to do something..
>
> Dim favoritecolor As String
>
> Select Case name
>
> Case "x"
> favoritecolor = "x"
>
> Case "y"
> favoritecolor = "y"
>
> Case "z"
> favoritecolor = "z"
>
> Case "a"
> favoritecolor = "a"
>
> Case "b"
> favoritecolor = "b"
> End Select
>
> MessageBox.Show(name & "'s favorite color is " &
>favoritecolor, "select demo")
>
>End Sub
>.
>



Relevant Pages

  • Re: Simple Button Question
    ... Private Sub Button1_Click(ByVal sender As System.Object, ... There's no reason to "click" the button with code. ... It's not as if calling ...
    (microsoft.public.vb.syntax)
  • Re: testing to see if an event has fired
    ... The problem is that the code doesn't run for some reason. ... Private Sub WebBrowser1_DocumentCompleted(ByVal sender As ... PerformClick method in Webbrowser's DocumentCompleted event sub to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: CONTEXTMENU
    ... But how do you put an event handler at the level of contextmenu that ... The reason I want to this is a want to link all the menuitems to the ... Private Sub ContextMenuStrip1_itemclick(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: testing to see if an event has fired
    ... The problem is that the code doesn't run for some reason. ... Private Sub WebBrowser1_DocumentCompleted(ByVal sender As ... PerformClick method in Webbrowser's DocumentCompleted event sub to ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Datagrid and dataset haschanges problem
    ... Reason I use a dataview is that I won't allow the user to ... Private Sub frmEditOptions_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.general)