Re: Messagebox displaying without being called

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



#1 Root cause

Use Option Strict On. It should spot possibly conversion error at compile
time rather than at runtime. This is AFAIK the exact text you'll have if you
try to do some code such as :

Dim o As Object=dt.DefaultView(0) ' Get the first DataRowView
Dim i as Integer=CInt(o) ' Should raise the exact error message you get
(translated from French I get the same than yours).

You can enable this file by file if it causes a massive amount of code to
update but this is a good practice so it's likely better to upgrade this
when you have time..

#2 Why this is not seen as an exception

Have you checked if you have a global error handler or which event are
handled on this combobox ? (such as BindingContextChanged, Format etc...)
taht would contain a messagebox statement ?

It could be also a built in error message (especially when the default
formatting happens) but for now I would say rather user code as what you
shown seems legal...

--
Patrice


"shawn.yu" <shawn.yu@xxxxxxxxxxxxxxxxxxxxxxxxx> a écrit dans le message de
groupe de discussion : 54C5C49A-55E5-4181-B50B-61E8EAB07267@xxxxxxxxxxxxxxxx
When a certain line of code is called, a messagebox is displayed to the
user
with the message "Conversion from type 'DataRowView' to type 'Integer' is
not
valid.". The strange thing is that I am not telling a messagebox to be
displayed (I am not calling MessageBox.Show or anything similar). No
exception is thrown. The line of code is still executed successfully.

Here is the method:

Public Shared Sub PopulateMonthDropDown(ByVal cboMonth As ComboBox, ByVal
month As Integer)
Dim dt As DataTable = New DataTable("month")

dt.Columns.Add("monthcode", GetType(Integer))
dt.Columns.Add("monthstring", GetType(String))

dt.Rows.Add(New Object() {1, "January"})
dt.Rows.Add(New Object() {2, "February"})
dt.Rows.Add(New Object() {3, "March"})
dt.Rows.Add(New Object() {4, "April"})
dt.Rows.Add(New Object() {5, "May"})
dt.Rows.Add(New Object() {6, "June"})
dt.Rows.Add(New Object() {7, "July"})
dt.Rows.Add(New Object() {8, "August"})
dt.Rows.Add(New Object() {9, "September"})
dt.Rows.Add(New Object() {10, "October"})
dt.Rows.Add(New Object() {11, "November"})
dt.Rows.Add(New Object() {12, "December"})

cboMonth.DataSource = dt 'Message is dispalyed here
cboMonth.DisplayMember = "monthstring"
cboMonth.ValueMember = "monthcode"
cboMonth.SelectedValue = month
End Sub

As per the comment, the messagebox is displayed when I call
cboMonth.DataSource = dt. What can cause message boxes to be displayed
without directly telling them to?


.



Relevant Pages

  • Re: Scripting.Dictionary.Item property requires left hand value?
    ... This code throws "Object doesn't support this property or method" exception ... If you don't have the assignment operator aka "=" on either the right ... get_/put_ prefixes. ... It will most likely not find the exact member's name, ...
    (microsoft.public.scripting.jscript)
  • Re: how can I run .net logon script application
    ... Nicole, just so you know, he's trying to do some AD stuff. ... rules are the same in COM interop case. ... >> I give you all the details from the dialogbox exception. ... > You included the following not quite exact blurb in your prior message: ...
    (microsoft.public.dotnet.security)
  • Re: Singles to Doubles
    ... Dim d1 As Double ... The best representation of a value as a single can use all 24 bits of mantissa, ... In the string domain the value is exact, and can be converted to a double using all 53 bits of precision. ...
    (microsoft.public.vb.general.discussion)
  • Re: Try...Catch across assemblies
    ... Throwing an exception from the Load event handler ... > That's the opposite behaviour from what's being reported here. ... > haven't even run my test program in VS - it's running it from the ... effecively the exact opposite. ...
    (microsoft.public.dotnet.framework)
  • Re: STOP in Fortran 2003
    ... the associated exception occurs. ... IEEE SET STATUS." ... the exact same bit pattern and doesn't generate any IEEE ... I'd say the the "interpretation" of A/B if to 1) compute ...
    (comp.lang.fortran)