G
Guest
Hello,
I have some code below that works, but I have to turn option strict off.
Basically I am allowing a user to change the IP of an Adapter. Since they may
have multiple adapters I read the Description and associated ServiceName from
the registry and then bind the arraylist to a combo box. I want to make sure
the adapter that has "MT" is selected by default. I always know the hardware,
since it is running XP embedded on a specific platform.
The line that is not correct is
enumNicServiceName.Current.Description.ToString. How do I make the
Description, which is a property of an object in the arraylist, safe or
strongly typed or what ever it needs to be.
Dim NICServiceName As ArrayList 'populated by a function in another
class not shown here
Dim enumNicServiceName As IEnumerator = NICServiceName.GetEnumerator()
'searches for both strings "M" and "T" and makes sure they are found
as "MT"
Do While enumNicServiceName.MoveNext
DefaultNic = enumNicServiceName.Current.Description.ToString
firstChar = InStr(DefaultNic, "M", CompareMethod.Text)
If firstChar > 0 Then
secondChar = InStr(firstChar, DefaultNic, "T",
CompareMethod.Binary)
If firstChar + 1 = secondChar Then
selectedNic = i
Exit Do
End If
End If
selectedNic = i
i += 1
Loop
I have some code below that works, but I have to turn option strict off.
Basically I am allowing a user to change the IP of an Adapter. Since they may
have multiple adapters I read the Description and associated ServiceName from
the registry and then bind the arraylist to a combo box. I want to make sure
the adapter that has "MT" is selected by default. I always know the hardware,
since it is running XP embedded on a specific platform.
The line that is not correct is
enumNicServiceName.Current.Description.ToString. How do I make the
Description, which is a property of an object in the arraylist, safe or
strongly typed or what ever it needs to be.
Dim NICServiceName As ArrayList 'populated by a function in another
class not shown here
Dim enumNicServiceName As IEnumerator = NICServiceName.GetEnumerator()
'searches for both strings "M" and "T" and makes sure they are found
as "MT"
Do While enumNicServiceName.MoveNext
DefaultNic = enumNicServiceName.Current.Description.ToString
firstChar = InStr(DefaultNic, "M", CompareMethod.Text)
If firstChar > 0 Then
secondChar = InStr(firstChar, DefaultNic, "T",
CompareMethod.Binary)
If firstChar + 1 = secondChar Then
selectedNic = i
Exit Do
End If
End If
selectedNic = i
i += 1
Loop