p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   VB.NET 2002/2003 Basics (http://p2p.wrox.com/forumdisplay.php?f=76)
-   -   Error, Strict On disallows implicit conversions f (http://p2p.wrox.com/showthread.php?t=23362)

vbGaz January 3rd, 2005 04:27 AM

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 ideas...it's driving me mad! :(

All times are GMT -4. The time now is 06:12 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.