Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 3rd, 2005, 04:27 AM
Registered User
Join Date: Jan 2005
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 ideas...it's driving me mad! :(

Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL conversions - chapter 7 gorillapoop BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 2 February 15th, 2011 11:02 AM
implicit conversion seymour_glass C# 7 November 4th, 2007 05:42 PM
Option Strict On disallows late binding. binici ASP.NET 2.0 Basics 2 March 2nd, 2007 07:38 PM
Type Conversions nikotromus Access VBA 2 October 7th, 2004 05:30 PM
Time conversions from 24hr to am/pm Blaise Classic ASP Basics 2 July 14th, 2003 09:38 PM

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