C
Charlie Smith
Hi all,
I have been following this ng lately and appreciate the level of
understanding I see as well as the dedication to helping others. Many
thanks for all the useful information I have picked up.
I have seen the recommendation for 'option strict' many times and
realized that I had not set it on in my current project. When I did I
discovered a number of small things and one that has me stumped. I am
sure that is a result of my lack of understanding of VB.NET, so I hope
you can help. Here is the code:
Private Sub InitializeCombo()
Dim objDataRow As DataRow
Dim mIndex As Integer
Dim mRowID As Integer
Dim objItem As ComboBoxItem
Me.ComboBoxUser.Items.Clear()
For mIndex = 0 To localData.Tables(0).Rows.Count - 1
objDataRow = localData.Tables(0).Rows.Item(mIndex)
objItem = New
ComboBoxItem((Int32.Parse(objDataRow.Item("lID").ToString)),
(objDataRow.Item("lUser").ToString))
Me.ComboBoxUser.Items.Add(objItem)
Next
Me.ComboBoxUser.SelectedIndex = 0
End Sub
Dim objItem As ComboBoxUser = Me.ComboBoxUser.SelectedItem
the last line is in several places and makes perfect sense to me, but
option strict tells me "Option Strict On disallows implicit
conversions from System.Object to StorageMinder.ComboBoxItem"
since the ComboBoxUser.Items collection was built with ComboBoxItem
objects, can't I expect it to return same?
Thanks,
Charlie Smith
I have been following this ng lately and appreciate the level of
understanding I see as well as the dedication to helping others. Many
thanks for all the useful information I have picked up.
I have seen the recommendation for 'option strict' many times and
realized that I had not set it on in my current project. When I did I
discovered a number of small things and one that has me stumped. I am
sure that is a result of my lack of understanding of VB.NET, so I hope
you can help. Here is the code:
Private Sub InitializeCombo()
Dim objDataRow As DataRow
Dim mIndex As Integer
Dim mRowID As Integer
Dim objItem As ComboBoxItem
Me.ComboBoxUser.Items.Clear()
For mIndex = 0 To localData.Tables(0).Rows.Count - 1
objDataRow = localData.Tables(0).Rows.Item(mIndex)
objItem = New
ComboBoxItem((Int32.Parse(objDataRow.Item("lID").ToString)),
(objDataRow.Item("lUser").ToString))
Me.ComboBoxUser.Items.Add(objItem)
Next
Me.ComboBoxUser.SelectedIndex = 0
End Sub
Dim objItem As ComboBoxUser = Me.ComboBoxUser.SelectedItem
the last line is in several places and makes perfect sense to me, but
option strict tells me "Option Strict On disallows implicit
conversions from System.Object to StorageMinder.ComboBoxItem"
since the ComboBoxUser.Items collection was built with ComboBoxItem
objects, can't I expect it to return same?
Thanks,
Charlie Smith