View Single Post
  #1 (permalink)  
Old January 3rd, 2005, 04:27 AM
vbGaz vbGaz is offline
Registered User
Join Date: Jan 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error, Strict On disallows implicit conversions f

I have recently bought the Wrox VB.NET 2003 book ISBN 0764556584, which is great! I have entered some code from Chapter 4, page 105, Using Select Case Project.

 Private Sub lstData_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstData.SelectedIndexChanged
        ' what did you choose?
        Dim name As String
        [red]name = lstData.Items(lstData.SelectedIndex)[red]

        ' use a select case to do something...
        Dim favoriteColor As String

        Select Case name.ToLower

            Case "darren", "edward"
                MessageBox.Show("Male", "Select Demo")

            Case "stephanie", "cathy", "zoe"
                MessageBox.Show("Female", "Select Demo")

            Case Else
                MessageBox.Show("I don't know the ************ of this person.", _
                                "Select Demo")

        End Select
    End Sub

When I run the project I get the following ERROR > [red]C:\Documents and Settings\Gary & Jackie\My Documents\Gary\Programming\Vbnet\Select Case\Select Case\Form1.vb(64): Option Strict On disallows implicit conversions from 'System.Object' to 'String'.[red] The error relates to the line name = lstData.Items(lstData.SelectedIndex)above.

Now here's my problem.....when I download the exact same code from the website it works! (I have Strict on for that code too)!

Any's driving me mad! :(

Reply With Quote