Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

At the following code line it is giving me an invalid cast exception not sure why. Keeping in mind that option strict is on. Any given would be greatly appreiciated.

 

Dim tindex as integer

 

tindex = Convert.ToInt32(ComboBox4.SelectedValue)

Posted

Its going to depend a lot on where your code is actually executing.

 

You might try

If (Me.ComboBox4.SelectedIndex <> -1) Then
  Dim tindex as Integer = CInt(Me.ComboBox4.SelectedItem.ToString())
End If

"In the immortal words of Socrates, who said "' I drank what?!'"
  • Leaders
Posted
Is there a SelectedValue property? Or are you referring to SelectedItem? Like PlausiblyDamp said, check the value of SelectedItem (or SelectedItem.ToString). Could be that it is nothing or an invalid string. Check either that (.SelectedIndex <> -1) or that (Not .SelectedItem Is Nothing).
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...