I can run the code fine without the Option Strict on, but once it's turned on, I run in to a "Option Strict On Disallows Late Binding"...why!?! I can't figure out how to fix it....

'Option Strict On'

Public Class StateFinderForm

    Private Sub FullStateNameRadio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FullStateNameRadio.CheckedChanged

        If FullStateNameRadio.Enabled = True Then
            FullStateNameText.Enabled = True
            StateAbbrevText.Enabled = False
            StateList.Enabled = True
            AbbrevList.Enabled = False
        End If

    End Sub

    Private Sub StateAbbrevRadio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StateAbbrevRadio.CheckedChanged

        If StateAbbrevRadio.Enabled = True Then
            FullStateNameText.Enabled = False
            StateAbbrevText.Enabled = True
            AbbrevList.Enabled = True
            StateList.Enabled = False
        End If
    End Sub

    Private Sub FullStateNameText_TextChanged(ByVal sender As System.Object, _
                ByVal e As System.EventArgs) Handles FullStateNameText.TextChanged


        Dim i As Integer
        Dim Found As Boolean
        Dim textStr, listStr As String

        textStr = FullStateNameText.Text.Trim.ToUpper
        Do While Not Found And i < StateList.Items.Count
            listStr = StateList.Items(i).toUpper
            If listStr.StartsWith(textStr) Then
                StateList.SelectedIndex = i
                Found = True
            Else
                i += 1
            End If
        Loop
        If Not Found Or textStr = String.Empty Then
            StateList.SelectedIndex = -1
            MessageBox.Show("Item Cannot Be Found OR Entry is Blank", "Input Error", _
                            MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If

    End Sub

    Private Sub StateAbbrevText_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StateAbbrevText.TextChanged

        Dim i As Integer
        Dim Found As Boolean
        Dim textStr, listStr As String

        textStr = StateAbbrevText.Text.Trim.ToUpper
        Do While Not Found And i < AbbrevList.Items.Count
            listStr = AbbrevList.Items(i).toUpper
            If listStr.StartsWith(textStr) Then
                AbbrevList.SelectedIndex = i
                Found = True
            Else
                i += 1
            End If
        Loop
        If Not Found Or textStr = String.Empty Then
            AbbrevList.SelectedIndex = -1
            MessageBox.Show("Item Cannot Be Found OR Entry is Blank", "Input Error", _
                            MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If

    End Sub
End Class

Recommended Answers

All 3 Replies

StateList.Items(i).toUpper
AbbrevList.Items(i).toUpper

Both items are not type of string by default. so if you want to assign these items as string just do:
StateList.Items(i).tostring.toUpper
AbbrevList.Items(i).tostring.toUpper

StateList.Items(i).toUpper
AbbrevList.Items(i).toUpper

Both items are not type of string by default. so if you want to assign these items as string just do:
StateList.Items(i).tostring.toUpper
AbbrevList.Items(i).tostring.toUpper

Thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.