473,407 Members | 2,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Combobox Weirdness

Don
I'm getting a strange error from the following code:

With Me.Combobox

' Clear list
.Items.Clear()

' Add items to the list
.Items.Add("item1")
.Items.Add("item2")
.Items.Add("item3")

' Select the default item
.SelectedItem = "item3" ' <--- This causes an exception

End With
The exception raised when trying to set the SelectedItem property of the
combox is:

Cast from string "item3" to type 'Integer' is not valid

I'm 100% sure this code used to work. I hadn't touched that project for
about a month, then I came back to it to fix up some code so that it would
compile with Option Strict on, but this code wasn't touched. I turned
Option Strict back off and it still craps out. The error message itself
doesn't make anysense because the SelectedItem property takes an Object, not
an integer, and the entire list is populated with strings, not integer.
What gives?

- Don
Nov 20 '05 #1
3 950
* "Don" <un*****@oblivion.com> scripsit:
I'm getting a strange error from the following code:

With Me.Combobox

' Clear list
.Items.Clear()

' Add items to the list
.Items.Add("item1")
.Items.Add("item2")
.Items.Add("item3")

' Select the default item
.SelectedItem = "item3" ' <--- This causes an exception

End With
The exception raised when trying to set the SelectedItem property of the
combox is:

Cast from string "item3" to type 'Integer' is not valid


Works perfectly for me. Are you sure you are assigning to
'SelectedItem' and not to 'SelectedIndex'?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Don

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
* "Don" <un*****@oblivion.com> scripsit:

The exception raised when trying to set the SelectedItem property of the
combox is:

Cast from string "item3" to type 'Integer' is not valid


Works perfectly for me. Are you sure you are assigning to
'SelectedItem' and not to 'SelectedIndex'?


Yup. SelectedItem. I think this must be some obscure VB bug or something
as there are other parts of my code that do just that and work fine. I have
no idea why it started happening. I guess I'll just have to chop that bit
of code it out, along with the combobox itself, and redo it.

- Don
Nov 20 '05 #3
Don
Ah, never mind. I figured it out. I had code in the SelectedIndexChanged
event that I had modified improperly. :-P

- Don
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Corne' Cornelius | last post by:
Hi, I'm experiencing some weirdness in a program, when subtracting 2 (double)'s which should result in 0, but instead it returns -1.11022e-16. It looks to me that changing the double x_step...
1
by: (Pete Cresswell) | last post by:
TabControl on the right side of a form with two tabs: Tab #1 contains two subforms that show some dynamic query results. Tab #2 contains a ListView that gets dynamically populated as the user...
0
by: Bruce B | last post by:
Hi group, I'm experiencing some extreme weirdness over the last week with IIS related to it's Mappings and how .NET is behaving. I can't explain the behavior as it seems very random. Our...
1
by: VB Programmer | last post by:
My development machine has been working perfectly, writing ASP.NET apps, etc... I just went to open a project and it said: "Visual Studio .NET has detected that the specified web server is not...
5
by: Phil Weber | last post by:
I'm attempting to debug an ASP.NET Web application in VS.NET 2003. I'm running the app and the debugger on my local machine (Windows XP Professional). I am logged in as a local administrator. In...
5
by: David Thielen | last post by:
Hi; I am creating png files in my ASP .NET app. When I am running under Windows 2003/IIS 6, the file is not given the security permissions it should have. It does not have any permission for...
1
by: rhino | last post by:
I've got some positioning problems that I can't figure out. Can anyone help? My website was working fine in IE7 and the current releases of Firefox and Opera so I had a look at it in IE6 and...
26
by: Prisoner at War | last post by:
Hi, All: I have a JavaScript search engine that always causes MSIE 7 to do a top-of-page security "warning" (that top-of-page-bar, and not an "alert" )...but other websites' JavaScripts do not...
2
by: JYA | last post by:
Hi. I was writing an xmltv parser using python when I faced some weirdness that I couldn't explain. What I'm doing, is read an xml file, create another dom object and copy the element from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.